AndroidManifest.xml
<uses-permission android:name="android.permission.WAKE_LOCK" />
Source:
private
PowerManager.WakeLock mWLock;
@Override
protected void onStart() {
super.onStart();
try {
PowerManager pm =
(PowerManager)getSystemService(Context.POWER_SERVICE);
mWLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
|
PowerManager.FULL_WAKE_LOCK
|
PowerManager.ACQUIRE_CAUSES_WAKEUP, "Lock Name");
mWLock.acquire();
}
catch(Exception e) {
Log.e("ScreenLock", "onStart()::acquire()
failed " + e.toString());
}
}
@Override
protected void onStop() {
try {
mWLock.release();
} catch(Exception
e) {}
}
No comments:
Post a Comment