import android.app.Activity;
Permission:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.Context;
import android.os.PowerManager;
import android.view.WindowManager;
public class AutoLock extends Activity
{
KeyguardManager keyguardManager;
KeyguardLock lock;
public void Disable_AutoLock()
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
keyguardManager = (KeyguardManager)
getSystemService(Activity.KEYGUARD_SERVICE);
lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
}
public void Enable_AutoLock()
{
lock.reenableKeyguard();
}
}
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
No comments:
Post a Comment