3

I have the following code. which is supposed to send a message in logcat at an interval but is not working. There are a lot of similar posts on stackoverflow but I am not able to figure out the problem. Is there a brainiac somewhere that can help me?

<receiver android:name="BoopoohooAlarmReceiver"></receiver>

public void startAlarmManager(long interval){
    Context context = getApplicationContext();
    Intent intent = new Intent(context, BoopoohooAlarmReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
    AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.add(Calendar.SECOND, 10);
    Log.i(DEBUG, "hollaa");
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), interval, pendingIntent);
}

public class BoopoohooAlarmReceiver extends BroadcastReceiver {
    private final String DEBUG = "BoopoohooAlarmReceiver"; 
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(DEBUG, "onReceive");
    }
}

Thanks.

djcharon
  • 319
  • 2
  • 9
  • 20

2 Answers2

6

Try to add the "." (point) in front of receiver name in the android manifest file declaration.

<receiver android:name=".BoopoohooAlarmReceiver"></receiver>

This may help too.

Andy Res
  • 15,963
  • 5
  • 60
  • 96
0

Refer this links Alarm Manager 1 , Alarm Manager 2 , Alarm Manager 3it will be helpful

Community
  • 1
  • 1
Andy
  • 123
  • 1
  • 1
  • 12