You may be mistaken, but if you want to make this Intent work, you should call:
context.startService(alarmIntent);
And let me know if this log is Log.v("log_tag", "Action :: "+intent.getAction()); on your Logcat, please, another Log.v("log_tag", "REPEAT"); .
I would suggest that your BroadcastReceiver would be like this:
public class ReceiverCall extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.v("log_tag", "Action :: "+intent.getAction()); if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Then on your Service in onCreate your Service add this:
Intent alarmIntent = new Intent(context, Whatever.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); manager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), + (1000 * 60 * 2), pendingIntent); Log.v("log_tag", "REPEAT");
I would also suggest creating a new BroadcastReceiver and on it do your things that you want to repeat, and replace whatever.class with BroadccastReceiver .
source share