Skip to content Skip to sidebar Skip to footer

How To Send A Message From An Intent Service To An Activity

Basically, i have an activity that has a progress dialog, i'm sending a message to an Intent to load all the data from the internet without any hiccup in the application. However,

Solution 1:

Try out as below:

privateHandlerhandler=newHandler() 
{
    publicvoidhandleMessage(Message message) 
    {
       finalIntentintent=newIntent(this, FillingDatabase.class);
       finalMessengermessenger=newMessenger(handler);
       intent.putExtra("messenger", messenger);
       startService(intent);
    };
};

Solution 2:

use

handler.dispatchMessage();

and send an empty message.declare handler static and access it by class name or simply create object of class and then access it.

i think you can also use

handler.SendEmptyMessage();

Solution 3:

Here comes your exact solution,

Issue was already solved here sending message from IntentService to Activity

And for more better understanding about this, Here comes an working example where you can directly use it for implementation Go here

Mark as OK if it works for you.

Post a Comment for "How To Send A Message From An Intent Service To An Activity"