我的应用程序内部添加了一个popup activity
,该应用程序在我的应用程序启动15秒后弹出。但是当我打开另一个activity
并回到我的main activity
弹出窗口再次显示。我希望它只在用户第一次打开应用程序时出现。我应该做什么改变?感谢帮助。仅在应用程序启动后显示弹出式动作
这里是弹出代码:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (context != null) {
AlertDialog.Builder alert = new AlertDialog.Builder(context, R.style.MyAlertDialogStyle)
.setTitle("Title")
.setMessage("Message")
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// continue with delete
Intent intent = new Intent(MainActivity.this, WebActivity.class);
startActivity(intent);
}
})
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int which) {
dialogInterface.dismiss();
// do nothing
}
});
mDialog = alert.create();
mDialog.getWindow().getAttributes().windowAnimations = R.style.MyAlertDialogStyle;
if (!((Activity) context).isFinishing())
mDialog.show();
// .setIcon(R.drawable.inr1)
// .show();
}
}
}, 15000);
您可以在sharedPrefrances中为此维护一个布尔变量。 – NaserShaikh
你只需要一次动作或者每当用户打开应用程序时 – koutuk
解雇你在'onResume'上弹出 – Mohit