On Fri, Jul 22, 2011 at 9:05 AM, Fred Niggle <fred.nig...@googlemail.com> wrote:
> Thanks for your reply.
>
> I guess my initial question can therefore be reduced to: How can an
> activity know when a service has performed a task?

You have no activity. That's the point.

Most medication dosing is on a 24-hour basis -- you take the
pills/drops/leeches once per day. The odds of your activity existing
at the point in time the 24-hour alarm goes off are negligible. Even
if the user had been visiting your application relatively recently,
Android terminates processes to free up RAM as it goes along. You must
not assume that you have an activity.

Hence, when the alarm goes off, if you want to pop up an activity, you
need to start one with startActivity(). If you are concerned about
there then possibly being *two* instances of your activity, add
FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_SINGLE_TOP to the Intent you
use with startActivity(). If you do have an existing instance of this
activity, it will come to the foreground and be called with
onNewIntent(); otherwise, a new instance will be created as normal.

I recommend that you also give the user an option for a Notification
instead of popping up an activity.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to