Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display Activity when the screen is locked?

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 ?

like image 847
Pachanka Avatar asked Sep 25 '10 09:09

Pachanka


People also ask

How do I show activity on lock screen?

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.

How wake up device and show an activity on top of lock screen for alarm?

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.

Can I put a To Do list on my lock screen?

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.


2 Answers

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*/ } 
like image 162
RN3KK Nick Avatar answered Oct 14 '22 13:10

RN3KK Nick


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.

like image 44
hackbod Avatar answered Oct 14 '22 13:10

hackbod