Android : GcmIntentService send message to running activity

on Friday, July 4, 2014


I have an android application where I need to notificate the user WHILE he's running an activity, that something happened. That message should be triggered by the GCM service. I've done everything to receive the message and I currently have my GcmIntentService working fine (following this link).


Now, I tried to send a Message to the activity, by defining a Handler in it like this:



public Handler _handler = new Handler() {
@Override
public void handleMessage(Message msg) {


I have 2 issues here:


1) I don't really know if this Handler is going to be triggered on the actual running activity


2) On this "handleMessage" event I don't have the running activity's context, so I can't, for instance, rise an AlertDialog


How can I achieve this? Should I have to re-think the communication between the service and the activity?


Thank you!


0 comments:

Post a Comment