Android AlertDialog Create getInstallationDialog(final Context context)

Here you can find the source of getInstallationDialog(final Context context)

Description

get Installation Dialog

License

LGPL

Declaration

public static Dialog getInstallationDialog(final Context context) 

Method Source Code

//package com.java2s;
/**/*from  www. j a  v a  2 s  .c  o  m*/
 * Copyright (C) 2012 SINTEF <fabien@fleurey.com>
 *
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.gnu.org/licenses/lgpl-3.0.txt
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;

import android.net.Uri;

public class Main {
    public static Dialog getInstallationDialog(final Context context) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage("SensApp application is needed. Would you like install it now?");
        builder.setCancelable(false);
        builder.setPositiveButton("Yes",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Uri uri = Uri.parse("market://details?id="
                                + "org.sensapp.android.sensappdroid");
                        try {
                            context.startActivity(new Intent(
                                    Intent.ACTION_VIEW, uri));
                        } catch (ActivityNotFoundException e) {
                            e.printStackTrace();
                        }
                    }
                });
        builder.setNegativeButton("No",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        return builder.create();
    }
}

Related

  1. newYesNoDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId, OnClickListener listener)
  2. newMessageDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId)
  3. showAuthenticatedDialog(Context context, String title, String text)
  4. showMessageDialog(Context context, String title, String strText)
  5. showSingleDialog(Context context, String title, String msg, boolean cancelable)
  6. showDialog(Context context, String title, String message)
  7. makeDialogBox(Context context, String title, String message, String cancleButton, DialogInterface.OnClickListener cancelCallBack, String okayButton, DialogInterface.OnClickListener okayCallBack)
  8. simpleDialogBox(Context context, String message)
  9. dismissProgressBar(ProgressDialog progressBar)