Start Activity From Lockscreen
I have created an app that uses a Broadcast Receiver. The Receiver needs to open another activity via intent. The program works when phone in unlocked / not sleeping. But when the
Solution 1:
use below code above setContentView(R.layout.main);
finalWindowwin= getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
now your activity will display even when your device is locked
Solution 2:
I guess your activity is paused when the phone sleeps, so you don't receive the Broadcast.
You could try to launch a Service. It will be able to run even in sleep mode (like your media player is able to play music even when the phone is locked)
Put your receiver in a Serive an start your activity from there. It should work
Post a Comment for "Start Activity From Lockscreen"