Intention Android unlock screen?

Is there an intention that starts when the user opens his screen? I want my application to adjust the brightness when the screen is turned on, but the problem I have to deal with is that the screen on the intent launches on the lock screen and does not adjust the display on this screen.

+7
android android-intent locking screen
source share
3 answers

Take a look at the disableKeyguard method in the KeyguardLock class.

+2
source share

Yes, ACTION_USER_PRESENT is sent after the user is unblocked:

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

Please note that this is a secure broadcast, and if a user uses a lock screen replacement, such as WidgetLocker or NoLock , USER_PRESENT cannot be sent or sent at the wrong time.

To detect WidgetLocker unlock see: http://teslacoilsw.com/widgetlocker/developers

+8
source share

Add receiver to manifest file

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

Create a broadcast receiver that works to open the application when the 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 am sure this will work.

+5
source share

All Articles