我有一个设置重复警报的应用程序,我希望它唤醒设备,解锁键盘保护,做一些事情,然后释放锁,准备在下一个警报时再次重复。它似乎可以工作,但手机仅在第一次触发警报时唤醒并解锁键盘保护,每次警报重复之后它不会打开屏幕并解锁,尽管警报触发的音频文件每次都会播放。我错过了什么?
public class RepeatingAlarmWake extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Wake up!");
wl.acquire();
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG");
keyguardLock.disableKeyguard();
PlayAudio2.INSTANCE.PlayAudio();
wl.release();
}
}