How to find whether phone is in sleep/idle mode for Android -
How to find whether phone is in sleep/idle mode for Android -
how find whether phone in sleep/idle mode android?
my problem able wake phone sleepmode using alarm manager
but when phone not sleep mode , @ same instant if alarm manager used wake phone..android forcefulness closes app..
whether there anyway find whether phone in sleep or idle mode?(black screen)
update:
my requirement:
when phone in sleep mode ---> intent should launched service when phone not in sleep mode --> same intent should launched service
none of solutions below worked here little tweak worked :):)
//pending intent alarm manager intent intentaa=new intent(this,mybroadcastreceiver.class); pendingintent pendingintent = pendingintent.getbroadcast(this, 0, intentaa, 0); //intent launched myintent intent intent intenta = new intent(); intenta.setclass(this, myintent.class); intenta.setflags(intent.flag_activity_new_task); //real code seek { startactivity(intenta); }catch(exception e) { alarmmanager = (alarmmanager)getsystemservice(alarm_service); am.set(alarmmanager.elapsed_realtime_wakeup,systemclock.elapsedrealtime(), pendingintent); startactivity(intenta); }
you can check if screen turned off calling isscreenon method.
note:this can used 2.1 , above..
android
Comments
Post a Comment