I am using android-c2dm, and my device successfully receives messages from it. I want to call a non-static function (in an already-existing Activity) to do something with that message, but simply calling it from C2DMBaseReceiver is illegal. How can I transfer this information back to the activity?
Edit: What if I call a static function to assign variables (or set Shared Preferences), then call a handler which will use those variables to do what needs to be done? Is that bad style?
What you could do is put the message details in an Intent somehow (the crudest way would be serialize the message to a String and add it as an Intent extra) and then send that Intent to the Activity using
startActivity. The Activity could check for the extra, know that it is a message, extract and deserialize the message and then go to town.You might need to set the appropriate launch mode or Intent flags if you want to make sure that an existing instance of the target Activity receives the message.