我不知道如何设置闹钟以便在5秒后显示Alert Dialog
让我做某事。
知道的人,
请帮助我,
谢谢,
p / s:我可以使用Alarm Manager
重启应用程序,如下所示。
public static void restartApplication(Context source, Context destination) {
// Restart the application by using the way : Set alarm timer to
// open the application again in a few seconds will be the better way
PendingIntent mPi = PendingIntent.getActivity(source, 0, new Intent(
new Intent(source, SplashScreen.class)), ((Activity) source)
.getIntent().getFlags());
AlarmManager mgr = (AlarmManager) ((Activity) source)
.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, mPi);
}
答案 0 :(得分:0)
您可以将Intent
设置为向其传递一些参数的活动,以便在其onResume
方法中显示对话框,例如:
Intent myIntent = new Intent(source, SplashScreen.class);
myIntent.putExtra("show_dialog",true);
PendingIntent mPi = PendingIntent.getActivity(source, 0,myIntent, ((Activity) source)
.getIntent().getFlags());
希望有所帮助