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:bizapps.com.healthforusPatient.activity.RegisterActivity.java

public void showErrorDialog(String msg, final boolean isVerify) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

    // set title//from   ww w.  j a  v  a  2 s  . c o m
    alertDialogBuilder.setTitle("Info");

    // set dialog message
    alertDialogBuilder.setMessage(msg).setCancelable(false).setNegativeButton("Okay",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    if (status.equalsIgnoreCase("success") && isVerify) {
                        verifyAccount();
                    } else {
                        Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.show();

}

From source file:git.lawpavilionprime.auth._Login.java

@Override
public void onBackPressed() {

    if (isAsyncTaskRunning) {
        AlertDialog.Builder builder = new AlertDialog.Builder(_Login.this);
        builder.setTitle("Info");
        builder.setMessage(//from   www .  j a va 2 s.  c o m
                "You are about to  exit the application\n\nYour Login is almost complete, Do you want to continue?")
                .setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.d("BACK", "BACK PRESSED");
                        mProgressBar.setVisibility(View.GONE);
                        AsyncManager.cancelAllTasks();
                        _Login.this.finish();
                    }
                }).setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
        backPressedDialog = builder.create();
        backPressedDialog.show();
    } else {
        super.onBackPressed();
    }
}

From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java

/**
 * ??Select/*from  ww  w . j av a 2 s.  c  o m*/
 * 
 * @param title
 * @param text
 * @return
 */
public int showAndroidSelect(final String title, final String text[]) {
    Runnable showSelect = new Runnable() {
        public void run() {
            final AlertDialog.Builder builder = new AlertDialog.Builder(LGameAndroid2DActivity.this);
            builder.setTitle(title);
            builder.setItems(text, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    androidSelect = item;
                }
            });
            builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    androidSelect = -1;
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    };
    runOnUiThread(showSelect);
    return androidSelect;
}

From source file:com.nadmm.airports.DownloadActivity.java

private void checkDelete() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Are you sure you want to delete all installed data?")
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                @Override/*from w w  w. jav  a2  s. c  o m*/
                public void onClick(DialogInterface dialog, int id) {
                    DeleteDataTask deleteTask = new DeleteDataTask();
                    deleteTask.execute((Void) null);
                }
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
    return;
}

From source file:fr.mdk.kisspush.KISSPush.java

protected void openAdd() {
    final Activity act = this;
    // get prompts.xml view
    LayoutInflater layoutInflater = getLayoutInflater();
    View promptView = layoutInflater.inflate(R.layout.prompts, null);
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(act);
    // set prompts.xml to be the layout file of the alertdialog
    // builder//from   w  w  w  .  j a  va2s  .c  om
    alertDialogBuilder.setView(promptView);
    final EditText input = (EditText) promptView.findViewById(R.id.userInput);
    // setup a dialog window
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // get user input and set it to
            // result
            if (input.getText().toString().length() > 0) {
                kiss_push_cli.add_alias(input.getText().toString(), new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
                        getAliases();
                    }
                });
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    // create an alert dialog
    AlertDialog alertD = alertDialogBuilder.create();
    alertD.show();

}

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

private void launchLoginDialog() {
    if (loginDlg == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(IbikeApplication.getString("login"));
        builder.setMessage(IbikeApplication.getString("error_not_logged_in"));
        builder.setPositiveButton(IbikeApplication.getString("login"), new DialogInterface.OnClickListener() {

            @Override//  www. j a  va2  s  .  co m
            public void onClick(DialogInterface dialog, int which) {
                Intent i = new Intent(MapActivity.this, LoginActivity.class);
                startActivity(i);
            }
        });
        builder.setNegativeButton(IbikeApplication.getString("close"), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        loginDlg = builder.create();
    }
    loginDlg.show();
}

From source file:com.abc.driver.TruckActivity.java

/**
 * edit portait/*from w  w  w.j  a v  a  2  s.  c o  m*/
 * 
 * @param v
 */
public void editDriverLicense(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(res.getString(R.string.choose_portrait));
    builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera),
            res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() {
                // @Override
                public void onClick(DialogInterface dialog, int id) {
                    switch (id) {
                    case 0:
                        startToCameraActivity(CellSiteConstants.TAKE_PICTURE);
                        break;
                    case 1:
                        startToMediaActivity(CellSiteConstants.PICK_PICTURE);
                        break;
                    }
                }

            });
    AlertDialog alert = builder.create();
    alert.show();

}

From source file:com.abc.driver.TruckActivity.java

/**
 * edit portait/*from  w  w w  . ja  va  2  s  .co m*/
 * 
 * @param v
 */
public void editPhotoImage(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(res.getString(R.string.choose_portrait));
    builder.setItems(new String[] { res.getString(R.string.getPhotoFromCamera),
            res.getString(R.string.getPhotoFromMemory) }, new DialogInterface.OnClickListener() {
                // @Override
                public void onClick(DialogInterface dialog, int id) {
                    switch (id) {
                    case 0:
                        startToCameraActivity(CellSiteConstants.TAKE_PICTURE2);
                        break;
                    case 1:
                        startToMediaActivity(CellSiteConstants.PICK_PICTURE2);
                        break;
                    }
                }

            });
    AlertDialog alert = builder.create();
    alert.show();

}

From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java

@Override
public void onUpdateFailed(Exception exception) {
    Log.e("update check failed", exception);
    if (updateProgressDialog != null) {
        updateProgressDialog.dismiss();//from w  w w. j a  v  a  2 s.c  om
    }

    AlertDialog.Builder builder = new Builder(activity);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setTitle(R.string.error_occured);
    builder.setMessage(R.string.update_couldn_t_be_completed);
    builder.setCancelable(false);
    if (update == null || !update.forceUpdate) {
        builder.setNeutralButton(R.string.continue_, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                onCompleted();
            }
        });

    } else {
        builder.setNeutralButton(R.string.exit_application, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                onExit();
            }
        });

    }
    builder.create().show();

}

From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java

private void showAlertDialog(String alertMessage) {
    if (this.isFinishing())
        return;/*from   ww  w  .  j a  v  a 2s .  c  o  m*/
    AlertDialog.Builder builder = new AlertDialog.Builder(OpenHABMainActivity.this);
    builder.setMessage(alertMessage).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}