Java tutorial
//package com.java2s; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.util.Log; public class Main { public static void showMessageDialogWithNewIntent(final Activity curentActivity, Context context, String message, final Class newActivity, final String extras) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message).setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(curentActivity, newActivity); if (extras != null) { Log.i("LOGINSIGNUP", "=extras!=null in showMessageDialog"); i.putExtra("OAuthError", true); } Log.i("LOGINSIGNUP", "==after if in showMessageDialog"); curentActivity.startActivity(i); // curentActivity.finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }