Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { public static void showServiceError(Context context, int id) { String msg = ""; if (id == -1) { msg = "could not complete query. Missing parameter"; } else if (id == 0) { msg = "no data found"; } else { msg = "something bad happend"; } AlertDialog.Builder alert = new AlertDialog.Builder(context); // Setting Dialog Title alert.setTitle("Alarm"); // Setting Dialog Message alert.setMessage(msg); alert.setPositiveButton("Try Again", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // chkVersionData(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); alert.setCancelable(false); alert.show(); } }