Example usage for android.app AlertDialog.Builder create

List of usage examples for android.app AlertDialog.Builder create

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder create.

Prototype

public void create() 

Source Link

Document

Forces immediate creation of the dialog.

Usage

From source file:com.honeycomb.cocos2dx.Soccer.java

public void quitGame(JSONObject prms) {
    AlertDialog.Builder exitbuilder = new AlertDialog.Builder(this);
    exitbuilder.setTitle("Girl Superhero").setMessage(com.honeycomb.cocos2dx.R.string.QUIT_MESSAGE)
            .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    AndroidNDKHelper.SendMessageWithParameters("resetListener", getDict());
                }//from ww w  . jav  a  2 s.c  om
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog stopalert = exitbuilder.create();
    stopalert.show();
}

From source file:com.mhise.util.MHISEUtil.java

public static Dialog displayDialog(Context ctx, String message, String title) {

    AlertDialog.Builder alertDialogBuilder = null;
    try {/* w  ww.ja  v  a  2  s.c  o m*/
        if (!message.equals("") || !message.equals(null)) {

            alertDialogBuilder = new AlertDialog.Builder(ctx);

            alertDialogBuilder.setMessage(message);
            //alertDialogBuilder.setTitle(title);
            alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                }
            });
            // Showing Alert Message
            alertDialogBuilder.show();

        }
    } catch (NullPointerException e) {
        // TODO: handle exception

        Logger.debug("MHISEUtil-->Unable to display dialog message", "display dialog");

    }
    return alertDialogBuilder.create();
}

From source file:org.safegees.safegees.gui.view.MainActivity.java

public void setNoInternetAdvice(Context context) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(getResources().getString(R.string.splash_advice_first_use_advice)).setCancelable(false)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent i = getBaseContext().getPackageManager()
                            .getLaunchIntentForPackage(getBaseContext().getPackageName());
                    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(i);/*from  w  w w.  j  a  v  a2 s  .  c  o  m*/
                    //finish();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.cleanwiz.applock.service.AppUpdateService.java

public void checkVersion() {
    requestQueue = Volley.newRequestQueue(context);
    String url = "http://www.toolwiz.com/android/checkfiles.php";
    final String oldVersionString = getApplicationVersion();
    Uri.Builder builder = Uri.parse(url).buildUpon();
    builder.appendQueryParameter("uid", AndroidUtil.getUdid(context));
    builder.appendQueryParameter("version", oldVersionString);
    builder.appendQueryParameter("action", "checkfile");
    builder.appendQueryParameter("app", "locklocker");

    jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, builder.toString(), null,
            new Response.Listener<JSONObject>() {

                @Override//  w  w  w.j  a  va 2  s  . com
                public void onResponse(JSONObject arg0) {
                    // TODO Auto-generated method stub
                    LogUtil.e("colin", "success");
                    if (arg0.has("status")) {
                        try {
                            String status = arg0.getString("status");
                            if (Integer.valueOf(status) == 1) {
                                JSONObject msgJsonObject = arg0.getJSONObject("msg");
                                double version = msgJsonObject.getDouble("version");
                                if (Double.valueOf(oldVersionString) < version) {
                                    // ???
                                    String intro = msgJsonObject.getString("intro");
                                    AlertDialog.Builder alert = new AlertDialog.Builder(context);
                                    alert.setTitle("?").setMessage(intro)
                                            .setPositiveButton("", new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int which) {
                                                    // ??
                                                }
                                            })
                                            .setNegativeButton("?", new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int which) {
                                                    dialog.dismiss();
                                                }
                                            });
                                    alert.create().show();
                                }
                            } else {
                                LogUtil.e("colin", "check update status is error");
                            }
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            LogUtil.e("colin", "JSONException" + e.getMessage());
                            e.printStackTrace();
                        }
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError arg0) {
                    // TODO Auto-generated method stub

                }
            });
    requestQueue.add(jsonObjectRequest);
}

From source file:com.spoiledmilk.ibikecph.map.MapActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == ProfileActivity.RESULT_USER_DELETED) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(IbikeApplication.getString("account_deleted"));
        builder.setPositiveButton(IbikeApplication.getString("close"), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();/*from  w  w w  .ja  v  a 2s .c om*/
            }
        });
        dialog = builder.create();
        dialog.show();
    } else if (resultCode == SearchActivity.RESULT_SEARCH_ROUTE) {
        if (data != null) {
            Bundle extras = data.getExtras();
            Location start = Util.locationFromCoordinates(extras.getDouble("startLat"),
                    extras.getDouble("startLng"));
            Location endLocation = Util.locationFromCoordinates(extras.getDouble("endLat"),
                    extras.getDouble("endLng"));
            if (extras.containsKey("fromName"))
                source = extras.getString("fromName");
            else
                source = IbikeApplication.getString("current_position");
            if (extras.containsKey("toName"))
                destination = extras.getString("toName");
            else
                destination = "";
            new SMHttpRequest().getRoute(start, endLocation, null, MapActivity.this);
        }
    } else if (resultCode == SearchAutocompleteActivity.RESULT_AUTOTOCMPLETE_SET) {
        try {
            ((AddFavoriteFragment) getSupportFragmentManager().findFragmentById(R.id.leftContainer))
                    .onActivityResult(requestCode, resultCode, data);
        } catch (Exception e) {
            try {
                ((EditFavoriteFragment) getSupportFragmentManager().findFragmentById(R.id.leftContainer))
                        .onActivityResult(requestCode, resultCode, data);
            } catch (Exception ex) {
            }
        }
    } else if (resultCode == RESULT_RETURN_FROM_NAVIGATION) {
        btnSaveFavorite.setImageResource(R.drawable.drop_pin_selector);
        pinInfoLayout.setVisibility(View.GONE);
        mapFragment.pinView.setVisibility(View.GONE);
        if (mapFragment.pinB != null) {
            mapFragment.mapView.getOverlayManager().remove(mapFragment.pinB);
        }
        if (data != null && data.getExtras() != null && data.getExtras().containsKey("overlaysShown")) {
            refreshOverlays(data.getIntExtra("overlaysShown", 0));
        }
    }
}

From source file:de.da_sense.moses.client.service.MosesService.java

/**
 * This function will be executed on first run and shows some welcome
 * dialog./*from  ww w. j  ava  2s.  co  m*/
 * 
 * @param context
 *            The context under which the dialog is shown.
 */
private void showWelcomeDialog(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setIcon(R.drawable.ic_launcher);
    builder.setCancelable(false); // This blocks the 'BACK' button
    builder.setMessage(getString(R.string.welcome_to_moses_string));
    builder.setTitle(getString(R.string.welcome_to_moses_title_string));
    builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
    Log.d("MoSeS.SERVICE", "First login.");
    PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("first_start", false).commit();
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * //from w  w w .  java 2s  .c om
 * @return
 */
@Override
protected Dialog createCPUDialog() {
    AlertDialog.Builder builder;
    AlertDialog alertDialog;

    builder = new AlertDialog.Builder(this);
    builder.setView(createCPUListDialog());

    builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            removeDialog(CPU_DIALOG);
        }
    });
    if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) {
        builder.setMessage("CPU usages");
    }
    alertDialog = builder.create();
    alertDialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface arg0) {
            // TODO Auto-generated method stub
            currentDialogId = -1;
        }
    });
    return alertDialog;
}

From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java

private void createPinDialog() {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.enter_pin, null);
    enterPinText = findById(view, R.id.enterPin);
    pinText = findById(view, R.id.pin);//from ww  w  .  java2s . com
    pinText.setHint(Token.PinType.PIN2.name());
    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setPositiveButton(R.string.sign_button, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            tokenService.readCert(Token.CertType.CertSign, new CertificateInfoCallback());
        }
    }).setNegativeButton(R.string.cancel, null);
    builder.setView(view);
    pinDialog = builder.create();
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * Draw a view to display disk status.//from ww w  .  j a v a2  s.  co  m
 * 
 * @return a AlertDialog containing the view.
 */
@Override
protected Dialog createDiskDialog() {
    AlertDialog.Builder builder;
    AlertDialog alertDialog;

    builder = new AlertDialog.Builder(this);
    builder.setView(createDiskListDialog());

    builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            removeDialog(DISK_DIALOG);
        }
    });
    if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) {
        builder.setMessage("Disk usage");
    }
    alertDialog = builder.create();
    alertDialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface arg0) {
            // TODO Auto-generated method stub
            currentDialogId = -1;
        }
    });
    return alertDialog;
}

From source file:com.bt.heliniumstudentapp.UpdateClass.java

protected UpdateClass(final Activity context, boolean settings) {
    UpdateClass.context = context;//from  w w  w  .j  ava  2s.  c o m
    this.settings = settings;

    final AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder(
            new ContextThemeWrapper(context, MainActivity.themeDialog));

    updateDialogBuilder.setTitle(R.string.update_checking);

    updateDialogBuilder.setNegativeButton(R.string.cancel, null);
    updateDialogBuilder.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) { //FIXME Come on, don't do this up here
            ActivityCompat.requestPermissions(context, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1); //TODO See warning
            //FIXME Great, now everything is protected...
        }
    });

    updateDialogBuilder.setView(R.layout.dialog_update);

    updateDialog = updateDialogBuilder.create();

    updateDialog.setCanceledOnTouchOutside(true);

    if (settings) {
        updateDialog.show();

        updateDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);

        updateDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextColor(ContextCompat.getColor(context, MainActivity.accentPrimaryColor));
        updateDialog.getButton(AlertDialog.BUTTON_NEGATIVE)
                .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
    }
}