嗨,我正在制作一个警报应用程序。当警报时间到来时,我正在向用户显示一个对话框。但问题是我想在对话框出现时获取唤醒锁。就像收到短信时屏幕刚刚唤醒一样。
我试过这个但不工作
public class Alarm extends Activity{
PowerManager pm;
WakeLock wl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pm = (PowerManager) getSystemService(POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "FlashActivity");
wl.acquire()
showAlarmDialog();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
wl.release();
}
}
我也添加了唤醒锁权限。帮助将被appriciated :-)