当应用程序进入后台此警报弹出警报对话框时,重点是每次应用程序进入后台时都会收到该弹出警报,并提醒用户没有完成作业。
public void alertIfStopNotPressed(){
if(active){
this.runOnUiThread(new Runnable() {
public void run() {
callDialog();
}
});
}
}
public void callDialog(){
AlertDialog.Builder dlg = new AlertDialog.Builder(this)
.setTitle("UPOZORENJE!")
.setMessage("Pritisnite STOP ukoliko ste završili sastanak")
.setPositiveButton("U redu",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dlg.create().show();
}
这是线程部分......
if (clicked == false) {
if (thread == null) {
//thread for checking if operator has pushed stop button
thread = new Thread() {
@Override
public void run() {
try {
sleep(1500000);
alertIfStopNotPressed();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();
clicked = true;
}
答案 0 :(得分:0)