我有一个程序负责在几秒钟后在前台显示 AlertDialog:
ActivityManager am = (ActivityManager) getSystemServ();
if (am != null) {
List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1);
if (taskInfo != null && !taskInfo.isEmpty()) {
if (taskInfo.get(0) != null && taskInfo.get(0).topActivity != null) {
if (!MY_CLASS_NAME.equalsIgnoreCase(taskInfo.get(0).topActivity.getClassName())) {
new AlertDialog.Builder(this).setMessage("AAAAAAAAAAAAAAAAAAAAAAAAAAAA?")
.setTitle("Message").setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which){
}
}).show();
}
}
}
}
但是当应用程序进入前台时,AlertDialog 没有显示!请帮助我!谢谢!