[英]how can i make this alarm wake my device up when it is locked
我需要讓鬧鍾在鎖定狀態下喚醒我的設備,如何使該鬧鍾在鎖定狀態下喚醒設備,我嘗試了很多代碼,但是沒有用,
這是我的代碼
// Alert Code
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("confirmation");
alertDialog.setMessage("r u sure u wanna send it");
// Timer Code
pendingIntent = PendingIntent.getService(CreateNewForm_3.this, 0,
new Intent(CreateNewForm_3.this, MyAlarmService.class), 0);
Send.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
alertDialog.setButton("yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// -1- InshaAllah we've to send the Case info.
// here MMS
String FullCaseMsg = "name: " + case1.getName() + "$"
+ " gender: " + case1.getGender() + "$"
+ " Age: " + case1.getAge() + "$"
+ " clothes: " + case1.getClothes()
+ "$" + " MoreInfo: "
+ case1.getMoreInfo() + "$" + " time: "
+ case1.getTime() + "$" + " loc: "
+ case1.getLocation() + "$";
// -2- then show toast
Toast.makeText(CreateNewForm_3.this, "sent ", 0)
.show();
// test
// -3- starting timer
long firstTime = SystemClock.elapsedRealtime();
am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setRepeating(
AlarmManager.ELAPSED_REALTIME_WAKEUP,
firstTime + 10 * 1000, 30 * 1000,
pendingIntent);
// firstTime Will be the current_time + ( 10 *
// 60 * 1000) =)
// 10* 1000 will be (10 * 60 * 1000)
new Handler().postDelayed(new Runnable() {
public void run() {
bCancel.performClick();
}
}, (30 * 1000));
// ( 30 * 1000) will be firstTime + ( 2-
// duration)
/*Intent toRecentCases = new Intent(
CreateNewForm_3.this, LMPActivity.class);
startActivity(toRecentCases);*/
//4-add my case object to list View
//All_Static.MyCaseList.add(case1);
}
});
alertDialog.setButton2("no",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// here you can add functions
}
});
alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
alertDialog.show();
}
});
bCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
am.cancel(pendingIntent);
}
});
任何幫助將不勝感激預先感謝
關閉設備時,“ AlarmManager.ELAPSED_REALTIME_WAKEUP”確實會喚醒設備,但我認為沒有機會“解鎖”(固定或設置圖案?)設備,因為這將是安全問題。 (如果我錯了糾正我...)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.