SlowTree
SlowTree

Reputation: 1295

Is activity running

I've a little problem in my "timer" development. I've an activity that shows a timer and when the user press start it schedules an alarm with AlarmManager service. In the broadcast receiver I want to check if the activity Timer is running and visible in order to avoid unneeded notification. So the broadcast receiver should set notification only if the activity isn't in foreground. Any suggestion?

Thx, SL3

Upvotes: 0

Views: 1047

Answers (1)

yeradis
yeradis

Reputation: 5347

You can use a Singletone pattern or SharedPreference property and store there some kind of state.

So, from your activity you can write the state and from your broadcast receiver you can read that state and then decide what to do.

Upvotes: 3

Related Questions