Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:goo.TeaTimer.TimerActivity.java

/** { @inheritDoc} */
@Override// w ww  .  j  ava 2 s  . c om
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case PREF:
        startActivity(new Intent(this, TimerPrefActivity.class));
        break;

    case ABOUT:
        //new TimerAboutDialog(this).show();
        //break;
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.about, null);

        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.icon);
        alrt.setTitle(mImgUrl);
        alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        alrt.show();
        return true;

    default:
        return false;
    }
    return true;
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
 * Delete waypoint by id with confirmation dialog
 * /*w  ww . ja v  a2  s .  com*/
 * @param wpid
 */
private void deleteWaypoint(long wpid) {

    final long waypointId = wpid;

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.are_you_sure).setCancelable(true)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {

                    // delete waypoint from db

                    Waypoints.delete(app.getDatabase(), waypointId);

                    // cursor.requery();
                    updateWaypointsArray();

                    waypointsArrayAdapter.setItems(waypoints);
                    waypointsArrayAdapter.notifyDataSetChanged();

                    Toast.makeText(WaypointsListActivity.this, R.string.waypoint_deleted, Toast.LENGTH_SHORT)
                            .show();
                }
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });

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

}

From source file:com.google.appinventor.components.runtime.FusiontablesControl.java

private void showNoticeAndDie(String message, String title, String buttonText) {
    AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(title);/*  ww  w  . j a v  a 2 s. co  m*/
    // prevents the user from escaping the dialog by hitting the Back button
    alertDialog.setCancelable(false);
    alertDialog.setMessage(message);
    alertDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            activity.finish();
        }
    });
    alertDialog.show();
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

@Override
protected void onCreate(Bundle arg0) {
    // TODO Auto-generated method stub
    super.onCreate(arg0);
    Bundle extras = getIntent().getExtras();
    job_id = extras.getString("job_id");
    tempLat = extras.getInt("tempLat");
    tempLongi = extras.getInt("tempLongi");

    try {/*from   ww w.  j av a  2s  . c  om*/
        driver_id = Query.getJobInfo(job_id).getString("driver_id");
    } catch (JSONException e) {
    }

    clientpng = getResources().getDrawable(R.drawable.greendot);
    taxipng = getResources().getDrawable(R.drawable.cabs);

    setContentView(R.layout.onroute);
    map = (MapView) findViewById(R.id.mvOnroute);
    map.setBuiltInZoomControls(true);
    overlayList = map.getOverlays();

    mySubmittedPosition = new GeoPoint(tempLat, tempLongi);
    map.getController().setCenter(mySubmittedPosition);
    map.getController().setZoom(17);
    localpos();

    TextView tvTaxiLicense = (TextView) findViewById(R.id.tvTaxiLicense);
    //TextView tvTaxiType = (TextView) findViewById(R.id.tvTaxiType);

    tvTaxiLicense.setText(Query.getDriverDetail("license", driver_id));
    //tvTaxiType.setText(job_id);

    tvORTop = (TextView) findViewById(R.id.tvORTop);
    tvORTop.setText(Query.getDriverDetail("name", driver_id) + " is en route");
    getDriverPosition(driver_id);

    handlerboolean = true;

    handler.postDelayed(r, 5000);

    // ///////////////////////////// CANCEL BUTTON ///////////////
    // ////////////////////////////////////////////////////////////
    Button cancel = (Button) findViewById(R.id.bOnrouteCancelCall);
    cancel.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            try {

                JSONObject json = Query.getJobInfo(job_id);

                int starttime = json.getInt("datetime");

                // ////////////////// CANCEL BUTTON - REPORT NO SHOW /////
                if (starttime + 300 <= Query.getServerTime()) {
                    handlerboolean = false;
                    handler.removeCallbacks(r);

                    AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
                    dcancelbuilder
                            .setMessage("Job has been cancelled.\nWould you like to report a driver no-show?.");

                    // ///////// NO button - normal client cancel ////////
                    button_cancelJob(dcancelbuilder);
                    // ///////// YES button - report driver NO SHOW ////////
                    button_cancelJob_driverNoShow(dcancelbuilder);

                    dcancelbuilder.show();

                } else {
                    handlerboolean = false;
                    handler.removeCallbacks(r);

                    alertdialog_canceljob();
                }

            } catch (JSONException e) {
            }

        }
    });
}

From source file:cm.aptoide.pt.RemoteInTab.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == NEWREPO_FLAG) {
        if (data != null && data.hasExtra("update")) {
            final AlertDialog alrt = new AlertDialog.Builder(this).create();
            alrt.setTitle("Update repositories");
            alrt.setMessage("The list of repositories in use has been changed.\nDo you wish to update them?");
            alrt.setButton("Yes", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    updateRepos();/*from w ww.  j a v  a2 s .  com*/
                }
            });
            alrt.setButton2("No", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alrt.dismiss();
                }
            });
            alrt.show();
        }
    } else if (requestCode == SETTINGS_FLAG) {
        if (data != null && data.hasExtra("align")) {
            order_lst = data.getExtras().getString("align");
            prefEdit.putString("order_lst", order_lst);
            prefEdit.commit();
        }
    }
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
  * /*  ww w.  j  av  a  2  s . c  om*/
  */
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle item selection
    switch (item.getItemId()) {

    case R.id.deleteWaypointsMenuItem:

        // clear all waypoints with confirmation dialog
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.are_you_sure).setCancelable(true)
                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {

                        Waypoints.deleteAll(app.getDatabase());

                        updateWaypointsArray();// cursor.requery();

                        waypointsArrayAdapter.setItems(waypoints);
                        waypointsArrayAdapter.notifyDataSetChanged();

                        Toast.makeText(WaypointsListActivity.this, R.string.all_waypoints_deleted,
                                Toast.LENGTH_SHORT).show();

                    }

                }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();

        alert.show();

        return true;

    // import waypoints from external file
    case R.id.importMenuItem:

        // this.importFromTextFile();

        this.importFromXMLFile();

        return true;

    case R.id.exportMenuItem:

        exportWaypoints();

        return true;

    case R.id.showMapMenuItem:

        // startActivity(new Intent(this, WaypointsMapActivity.class));

        Intent i = new Intent(this, MyMapActivity.class);

        // using Bundle to pass track id into new activity
        Bundle b = new Bundle();
        b.putInt("mode", Constants.SHOW_ALL_WAYPOINTS);

        i.putExtras(b);
        startActivity(i);

        return true;

    default:

        return super.onOptionsItemSelected(item);

    }

}

From source file:com.clearcenter.mobile_demo.mdMainActivity.java

public void onCreate(Bundle bundle) {
    Log.i(TAG, "onCreate(" + bundle + ")");
    super.onCreate(bundle);

    setContentView(R.layout.main_activity);

    Log.i(TAG, "loading data from Intent");
    final Intent intent = getIntent();
    Log.i(TAG, "onCreate intent: " + intent);
    final Bundle extras = getIntent().getExtras();
    Log.i(TAG, "onCreate intent extras: " + extras);

    accounts_textview = (TextView) findViewById(R.id.accounts_textview);
    accounts_listview = (ListView) findViewById(R.id.accounts_listview);
    accounts_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1);
    accounts_listview.setAdapter(accounts_adapter);
    accounts_listview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0) {
                final Intent intent = new Intent(mdMainActivity.this, mdAuthenticatorActivity.class);
                mdMainActivity.this.startActivity(intent);
                //new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT), 0);
            } else {
                final Intent intent = new Intent(mdMainActivity.this, mdStatusActivity.class);
                intent.putExtra("nickname", mdMainActivity.this.accounts_adapter.getItem(position));
                mdMainActivity.this.startActivity(intent);
            }//from   ww w  .j  a  va2  s  . c  o  m
        }
    });

    accounts_listview.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0)
                return false;
            final String nickname = mdMainActivity.this.accounts_adapter.getItem(position);
            mdMainActivity.this.account_to_delete = nickname;
            AlertDialog alert_dialog = new AlertDialog.Builder(mdMainActivity.this).create();
            //alert_dialog.setIcon(R.drawable.ic_launcher);
            alert_dialog.setTitle("Remove System?");
            alert_dialog.setMessage("Are you sure you want to remove the " + nickname + " system account?");
            alert_dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Remove system",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            mdMainActivity.this.onRemoveAccount();
                        }
                    });
            alert_dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    });

            alert_dialog.show();
            return true;
        }
    });

    account_manager = AccountManager.get(this);
}

From source file:com.com2us.module.inapp.DefaultBilling.java

protected void showPreviousProgressInfoDialog(Activity activity, Runnable runnable) {
    String message;//from   www .  j a  v a2 s. com
    String okay;
    String language = this.moduleData.getLanguage();
    String country = this.moduleData.getCountry();
    if (TextUtils.equals("ko", language)) {
        message = "\uc9c0\uae09\ub418\uc9c0 \uc54a\uc740 \uc0c1\ud488\uc774 \uc788\uc2b5\ub2c8\ub2e4. \n\uc7ac \uc9c0\uae09\uc744 \uc2dc\ub3c4\ud569\ub2c8\ub2e4.";
        okay = "\ud655\uc778";
    } else if (TextUtils.equals("fr", language)) {
        message = "Echec de lattribution de certains objets. \nLe processus va recommencer.";
        okay = "OK";
    } else if (TextUtils.equals("de", language)) {
        message = "Nicht erhaltene Items vorhanden. \nVorgang wird wiederholt.";
        okay = "OK";
    } else if (TextUtils.equals("ja", language)) {
        message = "\u652f\u7d66\u3055\u308c\u3066\u306a\u3044\u30a2\u30a4\u30c6\u30e0\u304c\u3042\u308a\u307e\u3059\u3002 \n\u518d\u652f\u7d66\u3044\u305f\u3057\u307e\u3059\u3002";
        okay = "OK";
    } else if (TextUtils.equals("ru", language)) {
        message = "\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b. \n\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437.";
        okay = "OK";
    } else if (TextUtils.equals("tw", country)) {
        message = "\u5546\u54c1\u672a\u6210\u529f\u7d66\u4ed8\uff0c \n\u5c07\u5617\u8a66\u91cd\u65b0\u9818\u53d6\u3002";
        okay = "\u78ba\u8a8d";
    } else if (TextUtils.equals("cn", country)) {
        message = "\u5b58\u5728\u672a\u80fd\u652f\u4ed8\u7684\u5546\u54c1\u3002 \n\u5c06\u5c1d\u8bd5\u91cd\u65b0\u652f\u4ed8\u3002";
        okay = "\u786e\u8ba4";
    } else {
        message = "Failed to grant some items. \nThe process will restart.";
        okay = "OK";
    }
    final Activity activity2 = activity;
    final Runnable runnable2 = runnable;
    activity.runOnUiThread(new Runnable() {
        public void run() {
            AlertDialog dialog = new Builder(activity2).setIcon(17301659).setMessage(message)
                    .setPositiveButton(okay, new OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                        }
                    }).create();
            final Activity activity = activity2;
            final Runnable runnable = runnable2;
            dialog.setOnDismissListener(new OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    activity.runOnUiThread(runnable);
                }
            });
            dialog.show();
        }
    });
}

From source file:com.hybris.mobile.app.commerce.adapter.CartProductListAdapter.java

/**
 * Display the delete item dialog/*from w  w  w. ja  v a  2 s.  co  m*/
 *
 * @param positionToDelete
 */
private void showDeleteItemDialog(final int positionToDelete) {

    // Creating the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(getContext(), R.style.AlertDialogCustom));
    builder.setMessage(R.string.cart_menu_delete_item_confirmation_title).setPositiveButton(
            R.string.cart_menu_delete_item_remove_button, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    QueryCartEntry queryCartEntry = new QueryCartEntry();
                    queryCartEntry.setEntryNumber(positionToDelete + "");

                    CommerceApplication.getContentServiceHelper()
                            .deleteCartEntry(new ResponseReceiver<CartModification>() {
                                @Override
                                public void onResponse(Response<CartModification> response) {
                                    updateCart();
                                }

                                @Override
                                public void onError(Response<ErrorList> response) {
                                    UIUtils.showError(response, getContext());

                                    // Update the cart
                                    SessionHelper.updateCart(getContext(), mRequestId, false);
                                }
                            }, mRequestId, queryCartEntry, null, false, null, mOnRequestListener);
                }
            }).setNegativeButton(R.string.cancel, null);

    AlertDialog alert = builder.create();

    // The dialog is cancelable by 3 ways: cancel button, click outside the dialog, click on the back button
    alert.setCancelable(true);
    alert.setCanceledOnTouchOutside(true);
    alert.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            // We revert to the default quantity when we dismiss the dialog
            if (mSelectedQuantity != null) {
                mSelectedQuantity.getEditText().clearFocus();
                mSelectedQuantity.getEditText().setText(mSelectedQuantity.getDefaultValue() + "");
            }
        }
    });

    alert.show();
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void pingpicked(JSONObject json) {

    try {/* www.  jav  a  2  s. c  om*/

        int driverpicked = json.getInt("picked");
        int drivercancelled = json.getInt("dcancel");
        int starttime = json.getInt("datetime");

        // /////////////////////////////// DRIVER CANCEL ////////
        if (drivercancelled == 1) {

            // //// DRIVER CANCEL LATE /////

            if (starttime + 300 <= Query.getServerTime()) {
                handlerboolean = false;
                handler.removeCallbacks(r);

                AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
                dcancelbuilder
                        .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?.");

                // //// DRIVER CANCEL LATE - NO REPORT LATE/////
                button_cancelJob_noquery(dcancelbuilder);
                // //// DRIVER CANCEL LATE - REPORT LATE /////
                button_drivercancel_reportlate(dcancelbuilder);

                dcancelbuilder.show();

            } else {
                // /////////////////////////////// DRIVER CANCEL NO ALERTS -
                // WITHIN TIME LIMIT///////////////
                handlerboolean = false;
                handler.removeCallbacks(r);

                alertdialog_drivercancelintime();

            }
        }
        if (driverpicked == 1) {
            // /////////////////////////////// CONFIRM PICK UP
            // ///////////////////////////////////////////

            handlerboolean = false;
            handler.removeCallbacks(r);
            AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this);
            final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup);
            final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite);
            final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown);
            final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite);
            LinearLayout layout = new LinearLayout(OnrouteScreen.this);
            layout.setOrientation(1);
            layout.setGravity(17);

            TextView tx1 = new TextView(OnrouteScreen.this);
            tx1.setText("Driver says you have been picked up");
            tx1.setGravity(17);
            tx1.setTextSize(20);
            tx1.setTextColor(Color.WHITE);
            tx1.setPadding(10, 10, 10, 10);

            TextView tx2 = new TextView(OnrouteScreen.this);
            tx2.setText("Please rate your driver");
            tx2.setGravity(17);
            tx2.setTextSize(16);

            LinearLayout imglayout = new LinearLayout(OnrouteScreen.this);
            imglayout.setOrientation(0);
            imglayout.setGravity(17);

            final ImageView ivup = new ImageView(OnrouteScreen.this);
            ivup.setImageDrawable(thumbsupwhite);
            ivup.setClickable(true);
            ivup.setPadding(0, 5, 30, 5);
            final ImageView ivdown = new ImageView(OnrouteScreen.this);
            ivdown.setImageDrawable(thumbsdownwhite);
            ivdown.setClickable(true);
            ivup.setPadding(30, 5, 0, 5);
            imglayout.addView(ivup);
            imglayout.addView(ivdown);

            layout.addView(tx1);
            layout.addView(tx2);

            layout.addView(imglayout);
            // /////////////////////////////// CONFIRM PICK UP - RATINGS
            // ///////////////////////////////////////////

            ivup.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (thumbsupboolean == false) {
                        thumbsupboolean = true;
                        thumbsdownboolean = false;
                        ivup.setImageDrawable(thumbsup);
                        ivdown.setImageDrawable(thumbsdownwhite);
                        rating = 1;
                    } else {
                        thumbsupboolean = false;
                        ivup.setImageDrawable(thumbsupwhite);
                        rating = 0;
                    }

                }
            });

            ivdown.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (thumbsdownboolean == false) {
                        thumbsdownboolean = true;
                        thumbsupboolean = false;
                        ivdown.setImageDrawable(thumbsdown);
                        ivup.setImageDrawable(thumbsupwhite);

                        AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create();

                        alert.setMessage("Please pick one");
                        alert.setButton("No show", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -1;
                            }
                        });
                        alert.setButton2("Driver late", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -2;
                            }
                        });
                        alert.setButton3("Poor service", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -3;
                            }
                        });
                        alert.show();

                    } else {
                        thumbsupboolean = false;
                        ivdown.setImageDrawable(thumbsdownwhite);
                        rating = 0;
                    }

                }
            });

            button_completed_finish(alert);

            alert.setView(layout);
            alert.create();
            alert.show();
        } else {
        }

    } catch (JSONException e) {
    }
}