My application is launched on car docking event, I want to wake up phone (done by system) and unlock screen when I plug my device.
Is it posssible ?
To enable it you have to go to the app configuration -> Other permissions -> Show On Lock screen. The full screen activity will also not appear if you have an existing notification with the same id that has not been dismissed.
Update: If you want to show the Activity on the lock screen, you need to set showForAllUsers to true. Here's the description from the Android documentation: Specify that an Activity should be shown even if the current/foreground user is different from the user of the Activity. This will also force the android.
Add a Tasks widget On your Android, touch and hold any empty section of the Home screen. At the bottom, tap Widgets. Touch and hold a Tasks widget: The 1x1 widget: Adds a new task and directs you to the Tasks app.
I'm use for upping activity to top level
private Window wind; @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); /******block is needed to raise the application if the lock is*********/ wind = this.getWindow(); wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD); wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED); wind.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON); /* ^^^^^^^block is needed to raise the application if the lock is*/ }
Use Activity.getWindow() to get the window of your activity; use Window.addFlags() to add whichever of the following flags in WindowManager.LayoutParams that you desire: FLAG_DISMISS_KEYGUARD, FLAG_SHOW_WHEN_LOCKED, FLAG_TURN_SCREEN_ON
This is how the standard car dock (and desk dock) app implements this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With