警告框在 Intent 之前自动关闭
Alertbox closing Automatically before Intent
我想在我的 activity.after 单击 "ok" 按钮之前显示警报框,只有意图应该有效,但在我的情况下,警报框显示然后立即显示意图 working.I 意味着警报框在意图之前自动关闭。
这是我的 activity 代码
alert.showAlertDialogpostive(ChangePass.this, "Successfully Submited",
"Password Changed Successfully", true);
UserFunctions userFunction = new UserFunctions();
userFunction.logoutUser(getApplicationContext());
Intent dashboard = new Intent(getApplicationContext(), LoginActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
这是我的提醒生成器class
@SuppressWarnings("deprecation")
public void showAlertDialogpostive(Context context, String title, String message,
Boolean status) {
final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
alertDialog.setCancelable(false);
// Setting Dialog Message
alertDialog.setMessage(message);
if(status != null)
// Setting alert dialog icon
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.success);
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int which) {
alertDialog.dismiss();
}
});
// Showing Alert Message
alertDialog.show();
}
只有在警报中单击确定按钮后,Intent 才会起作用 box.help 我!
UserFunctions userFunction = new UserFunctions();
userFunction.logoutUser(getApplicationContext());
Intent dashboard = new Intent(getApplicationContext(), LoginActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
将上面的代码移到警报的按钮点击中。所以你的代码如下所示,
@SuppressWarnings("deprecation")
public void showAlertDialogpostive(Context context, String title, String message,
Boolean status) {
final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
alertDialog.setCancelable(false);
// Setting Dialog Message
alertDialog.setMessage(message);
if(status != null)
// Setting alert dialog icon
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.success);
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int which) {
UserFunctions userFunction = new UserFunctions();
userFunction.logoutUser(getApplicationContext());
Intent dashboard = new Intent(getApplicationContext(), LoginActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
}
});
// Showing Alert Message
alertDialog.show();
}
我想在我的 activity.after 单击 "ok" 按钮之前显示警报框,只有意图应该有效,但在我的情况下,警报框显示然后立即显示意图 working.I 意味着警报框在意图之前自动关闭。 这是我的 activity 代码
alert.showAlertDialogpostive(ChangePass.this, "Successfully Submited",
"Password Changed Successfully", true);
UserFunctions userFunction = new UserFunctions();
userFunction.logoutUser(getApplicationContext());
Intent dashboard = new Intent(getApplicationContext(), LoginActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
这是我的提醒生成器class
@SuppressWarnings("deprecation")
public void showAlertDialogpostive(Context context, String title, String message,
Boolean status) {
final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
alertDialog.setCancelable(false);
// Setting Dialog Message
alertDialog.setMessage(message);
if(status != null)
// Setting alert dialog icon
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.success);
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int which) {
alertDialog.dismiss();
}
});
// Showing Alert Message
alertDialog.show();
}
只有在警报中单击确定按钮后,Intent 才会起作用 box.help 我!
UserFunctions userFunction = new UserFunctions();
userFunction.logoutUser(getApplicationContext());
Intent dashboard = new Intent(getApplicationContext(), LoginActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
将上面的代码移到警报的按钮点击中。所以你的代码如下所示,
@SuppressWarnings("deprecation")
public void showAlertDialogpostive(Context context, String title, String message,
Boolean status) {
final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
alertDialog.setCancelable(false);
// Setting Dialog Message
alertDialog.setMessage(message);
if(status != null)
// Setting alert dialog icon
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.success);
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int which) {
UserFunctions userFunction = new UserFunctions();
userFunction.logoutUser(getApplicationContext());
Intent dashboard = new Intent(getApplicationContext(), LoginActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
}
});
// Showing Alert Message
alertDialog.show();
}