Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android unlock screen intent?

Is there an intent that is fired when a user unlocks their screen? I want my app to adjust the brightness when the screen turns on, but the problem im running into is that the screen on intent is fired on the lock screen and it does not adjust the display on that screen.

like image 792
John Avatar asked May 10 '10 13:05

John


People also ask

What is Full screen intent notification?

The interface used to describe a full-screen action for a notification. By setting a fullScreenAction , when the notification is displayed, it will launch a full-screen intent.

How do I show activity on lock screen instead of notification?

How do I show activity on Lock screen instead of notification? 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.


3 Answers

Yes, the ACTION_USER_PRESENT is broadcasted after the user unlocks:

http://developer.android.com/reference/android/content/Intent.html#ACTION_USER_PRESENT

Note that this is a protected broadcast and if the user is using a lock screen replacement such as WidgetLocker or NoLock the USER_PRESENT may not be sent or may be sent at the wrong time.

For detecting WidgetLocker's unlock see: http://teslacoilsw.com/widgetlocker/developers

like image 166
Kevin TeslaCoil Avatar answered Sep 28 '22 03:09

Kevin TeslaCoil


Add the receiver in menifest file

<receiver android:name=".ScreenReceiver">
            <intent-filter>
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>

Create a broadcast receiver which works to open app when phone is unlocked.

public class ScreenReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        System.out.println(intent.getAction());
        if (intent.getAction().equals(Intent.ACTION_USER_PRESENT))
        {
            Intent intent1 = new Intent(context,MainActivity.class); 
            intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);        
            context.startActivity(intent1);
        }
    }

I'm sure it will work.

like image 39
Naresh Sharma Avatar answered Sep 28 '22 04:09

Naresh Sharma


Look at the disableKeyguard method in the KeyguardLock class.

like image 31
Karan Avatar answered Sep 28 '22 03:09

Karan