java - How to get data from Service in IntentService? -


in app have service (mainservice) runs in background , handles data images, messages, etc.

i need show additional data (sender's avatar example) service in gcm notifications.

i've implemented gcm this:

gcmbroadcastreceiver.java:

public class gcmbroadcastreceiver extends wakefulbroadcastreceiver{     @override     public void onreceive(context context, intent intent){         componentname comp = new componentname(context.getpackagename(), gcmnotificationservice.class.getname());         startwakefulservice(context, (intent.setcomponent(comp)));         setresultcode(activity.result_ok);     } } 

gcmnotificationservice.java:

public class gcmnotificationservice extends intentservice{     @override     protected void onhandleintent(intent intent){         //need retreive data mainservice         //tried bind mainservice here         ...         //send notification         gcmbroadcastreceiver.completewakefulintent(intent);     } } 

the problem can't bind mainservice in onhandleintent because it's thread closes earlier receive onserviceconnected.

i tried extend intentservice in mainservice, it's bad idea.

what should achieve functionality?


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -