FabioCosta
FabioCosta

Reputation: 2749

Android AlarmManager call running activity

I have an alarm manager to check if my activity needs to be updated every 30 minutes or so. I want to send from the alarmManager to my running activity a message to it be reloaded. How i would do so? I tryied using startActivity from within the alarmManager but i was unsuccessful.

Upvotes: 0

Views: 148

Answers (1)

newbyca
newbyca

Reputation: 1513

Are you familiar with Activity's onNewIntent method? In your activity class you should be able to do something like this:

@Override
protected void onNewIntent(Intent i){
    refresh();
}

You could also pack some extra data into the PendingIntent you raise with AlarmManager and check it from onNewIntent if you need more logic.

Upvotes: 1

Related Questions