i have service run button in activity. service register broadcast receiver. kknow way data activity when onstartcommand method starts (bundle bundle = intent.getextras());
my question : how can if want data activity when ondestroy method starts ? in other words : want take care of checkboxes user checked when ondestroy method called because actions depends checkboxes.
any ideas ?
thanks
instead of calling stopservice can call startservice , pass in boolean "shutdown" equal true , other information want pass, in onstartcommand can check "shutdown" flag , process other pass in information , call stopself(). sample code
intent intent = new intent(this, myservice.class); intent.putextra("shutdown", true); intent.putextra(otherdata); startservice(intent);
in myservice onstartcommand
@override public int onstartcommand(intent intent, int flags, int startid) { if (intent != null) { // data , process if (intent.getbooleanextra("shutdown", false); { stopself(); } } return start_sticky; }
Comments
Post a Comment