答案 0 :(得分:0)
授予以下权限:
<uses-permission android:name="android.permission.WAKE_LOCK" />
并在java文件中:
PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock");
wakeLock.acquire();
在应用程序暂停或销毁或按下按钮时释放此锁定:
wakeLock.release();
希望它有所帮助。
几个链接:
disable-keyguard-and-display-an-activity-to-the-user
disabled-keyguard-lock-re-enables-itself-after-clicking-on-a-notification