How to display Activity when the screen is locked?

Pachanka picture Pachanka · Sep 25, 2010 · Viewed 35.6k times · Source

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 ?

Answer

RN3KK Nick picture RN3KK Nick · Feb 8, 2012

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*/
}