Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.AlertDialog; import android.content.Context; public class Main { private static boolean checkPIN(Context context, String PIN1, String PIN2) { boolean isOK = true; if (PIN1.length() != 4 && PIN2.length() != 4 || PIN1.contains(" ")) { String message = "Only 4 digits allowed"; showErrorDialog(context, message); isOK = false; } else { if (!PIN1.equals(PIN2)) { isOK = false; String message = "Both Values should be same"; showErrorDialog(context, message); } } return isOK; } public static void showErrorDialog(Context context, String message) { new AlertDialog.Builder(context).setTitle("Error").setMessage(message) .setPositiveButton(android.R.string.ok, null).setIcon(android.R.drawable.ic_dialog_alert).show(); } }