I have a service that runs in background with PARTIAL_WAKE_LOCK. It waits until someone shakes the device (using the accelerometer) and then turns the screen on and start an activity. I use this piece of code to unlock the screen:
PowerManager TempPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock TempWakeLock = TempPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE, "TempWakeLock");
TempWakeLock.acquire();
// do the work that needs the visible display...
It works pretty fine so far, but is there any way I could make the phone unlock itself once the screen is on, so that the user doesn't have to slide it manually or to write his password?
I tried using this:
mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
mLock = mKeyGuardManager.newKeyguardLock("activity_classname");
mLock.disableKeyguard();
However, I get this weird bug and the variable name is stroked...
The type KeyguardManager.KeyguardLock is deprecated
Add @SuppressWarnings 'deprecation' to 'mLock'
I dunno even if this is the correct solution, but it isn't working... Does anyone know what I should do?
To sum up, I intend to make a service that unlocks the screen, so that the user doesn't have to slide it or write his password, and then starts an activity... Any ideas??
Thank you!