android - Start Service from BroadcastReceiver never call service.onStartCommand() method -


i have music service playing audio files. start service activity. send notification play/pause button when click on play button notification send broadcast receiver , it's working. in on onreceive(context context, intent intent) method call context.startservice(intentservice) problem musicservice.onstartcommand() never called.

my receiver

public class playepisodereceiver extends broadcastreceiver {      @override     public void onreceive(context context, intent intent) {         toast.maketext(context, "service started", toast.length_short).show();         if(musicservice.isrunning()) {              intent serviceintent = new intent(context, musicservice.class);              serviceintent.putextra(appconstants.action_type, appconstants.action_play);              context.startservice(intent);         }     }  }  

my manifest:

<service             android:enabled="true"             android:name=".backgroundtasks.musicservice">             <intent-filter>                 <action                     android:name = "cc.gm.oscarradio.backgroundtasks.musicservice">                 </action>             </intent-filter>         </service>         <receiver             android:enabled="true"             android:name=".receivers.playepisodereceiver">             <intent-filter>                 <action android:name = "cc.gm.oscarradio.action_music"/>             </intent-filter>         </receiver> 

in code there should slight change feel, should replace following line:

context.startservice(intent); 

by

context.startservice(serviceintent); 

hope helps you.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -