get Ok Modal With Close App alert Dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

get Ok Modal With Close App alert Dialog

Demo Code

/**//from ww  w  .j a  v  a2s .  co m
 * Copyright (c) {2003,2011} {openmobster@gmail.com} {individual contributors as indicated by the @authors tag}.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
//package com.java2s;

import android.app.Activity;

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

public class Main {
    public static AlertDialog getOkModalWithCloseApp(
            final Activity currentActivity, String title, String message) {
        AlertDialog okModal = null;

        okModal = new AlertDialog.Builder(currentActivity).setTitle(title)
                .setMessage(message).setCancelable(false).create();
        okModal.setButton(DialogInterface.BUTTON_POSITIVE, "OK",
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int status) {
                        dialog.dismiss();
                        currentActivity.finish();
                    }
                });

        return okModal;
    }
}

Related Tutorials