android - Calling stopService in onActivityResult() is not effective -
in onactivityresult, wanted stop , restart service. i'm not able stop service code below.
if (requestcode == device_selection) { if(resultcode == result_ok) { intent = new intent(this, myservice.class); stopservice(i); } }
in debugging mode, able reach stopservice() line, app never calls ondestroy() of myservice class (which extends service class) , service not destroyed.
does have idea why case?
my service can started , able destroy service when stopservice() called in ondestroy() method of activity indicates me service class implemented correctly.
you need cache intent have started service use same intent stop service, work
for example lets intent = new intent(this, myservice.class); intent used start service startservice(i) , use same intent stop it. don't create new intent.
Comments
Post a Comment