android - Wake up device programmatically -
i want wake , unlock device. then, i'd show activity when user has new message firebase.
i wrote on onresume() method:
window = this.getwindow(); window.addflags(windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_dismiss_keyguard); window.addflags(windowmanager.layoutparams.flag_keep_screen_on | windowmanager.layoutparams.flag_turn_screen_on); this works devices api > 19. problem in kitkat, either nothing or wakes screen doesn't unlock device.
also set right permissions in androidmanifest.xml:
<uses-permission android:name="android.permission.receive_boot_completed" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.disable_keyguard" /> also in myfirebasemessagingservice.class, i'm starting activity flag_activity_new_task flag.
does know missing?
thanks help.
ok found it. add piece of code , worked
keyguardmanager manager = (keyguardmanager) this.getsystemservice(context.keyguard_service); keyguardmanager.keyguardlock lock = manager.newkeyguardlock("abc"); lock.disablekeyguard();
Comments
Post a Comment