Notification assistance.

by Damien Cooke » Sun, 12 Dec 2010 12:14:13 GMT

Sponsored Links
 Hi All,
I am crossing from iOS to Android development and am after a small amount of 
help with a concept.  In ios I can post notifications that can be listed for by 
other objects.  These are not seen by the user, they are totally internal to 
the application.  Is this type of systemic messaging available or do I need to 
more closely couple my classes?  or even completely rethink my design?

Thanks and sorry for the dumb question


Re: Notification assistance.

by DanH » Sun, 12 Dec 2010 13:03:58 GMT

 In Android the same basic function is accomplished with "intents".


Sponsored Links

Re: Re: Notification assistance.

by Dianne Hackborn » Mon, 13 Dec 2010 00:10:08 GMT


Well.  If this is all just in your app, I would generally just recommend
doing normal direct callbacks.  There isn't a generic "local callback
registry" API in Android, but this is trivial to build yourself -- just make
a class with an ArrayList<Callback> and functions to add and remove
callbacks, and perform a call on all callbacks.  It's 20 lines of code max.
 If you want to make it async, it's a couple more lines of code to have a
Handler that you post a Runnable on to, to do the callbacks.

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


Re: Notification assistance.

by Phil Endecott » Mon, 13 Dec 2010 03:20:52 GMT

 Hi Damien,

Write your own replacement.  On iOS I use my own simple notification
system, because Apple's version is overcomplicated.  For most cases
it's almost trivial to do; it only gets complicated if you need to
worry about threads, queuing, merging multiple notifications and
things like that.