設備未插入線進行充電 設備被設置閒置15秒後進入睡眠AlarmManager.RTC運行,即使設備處於睡眠
怪異的結果是,振動器保持運行每60秒當我設置我到60 這裏是我的報警代碼。
public void startAlert(View view) {
EditText text = (EditText) findViewById(R.id.time);
int i = Integer.parseInt(text.getText().toString());
Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), i*1000, pendingIntent);
Toast.makeText(this, "Alarm set in " + i + " seconds",
Toast.LENGTH_LONG).show();
}
的廣播接收器
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Time is up!!!!.",
Toast.LENGTH_LONG).show();
// Vibrate the mobile phone
Vibrator vibrator = (Vibrator) context
.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);
}
設備在設置菜單中處於非活動狀態15秒後設置爲休眠。你的意思是這不會讓設備進入睡眠狀態?請提供指向支持此聲明的任何文檔的鏈接 – anuj
@anuj我沒有doc鏈接,它的正確體驗。我擁有的最好的答案是我的更新答案和PowerManager和WakeLock的文檔。 – Lovis