Java tutorial
//package com.java2s; //License from project: Apache License import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.util.Log; public class Main { protected static final String TAG = "livroandroid"; @SuppressWarnings("deprecation") public static void alertDialog(final Context context, final int mensagem) { try { AlertDialog dialog = new AlertDialog.Builder(context).setTitle( // context.getString(R.string.app_name)).setMessage(mensagem).create(); "Teste").setMessage(mensagem).create(); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); dialog.show(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } @SuppressWarnings("deprecation") public static void alertDialog(final Context context, final String mensagem) { try { AlertDialog dialog = new AlertDialog.Builder(context).setTitle( // context.getString(R.string.app_name)).setMessage(mensagem).create(); "Teste").setMessage(mensagem).create(); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); dialog.show(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } }