Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Main {
    static void showDialog(Context context, int res_title, int res_message, boolean isFinish) {
        showDialog(context, context.getResources().getString(res_title),
                context.getResources().getString(res_message), isFinish);
    }

    static void showDialog(final Context context, String title, String message, final boolean isFinish) {

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(title);

        // set dialog message
        alertDialogBuilder.setCancelable(false).setMessage(message).setPositiveButton(android.R.string.ok,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                        if (isFinish)
                            ((Activity) context).finish();
                    }
                });

        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();

    }
}