android - When the device is sleep IntentService is not getting called -
i triggering intentservice wakefullbroadcastreceiver
intent = new intent(context, myservice.class); i.putextras(bundle); log.i("startservice","before wakelock"); wakelock lock = myservice.getlock(context); log.i("startservice","after wakelock"); lock.acquire(); log.i("startservice","after aquire"); context.startservice(i); lock.release(); log.i("startservice","after release");
all above logs getting displayed. service not getting called.
intentservice
public class myservice extends intentservice { private static final string name = myservice.class.getname() + ".lock"; private static volatile wakelock lockstatic = null; synchronized public static powermanager.wakelock getlock(context context) { if (lockstatic == null) { powermanager mgr = (powermanager) context .getsystemservice(context.power_service); lockstatic = mgr.newwakelock(powermanager.partial_wake_lock, name); lockstatic.setreferencecounted(true); } return (lockstatic); } public myservice(string name) { super(name); } public myservice() { super("myservice"); } @override protected void onhandleintent(intent intent) { try { log.i("intentservice", "in handleintent"); } { } } }
can me??
in oncreate() need add flags window. example:
@override protected void oncreate(bundle savedinstancestate) { getwindow().addflags(windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_dismiss_keyguard | windowmanager.layoutparams.flag_keep_screen_on | windowmanager.layoutparams.flag_turn_screen_on | windowmanager.layoutparams.flag_allow_lock_while_screen_on);` }
i have posted here check this
Comments
Post a Comment