Example usage for android.app AlertDialog.Builder setMessage

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

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java

private void showUploadPhotoPopup(final boolean isFinishingService) {
    AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
    adb.setTitle("Adjuntar imagen");
    adb.setMessage("Desea adjuntar una imagen al incidente?");
    adb.setPositiveButton("Si", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dispatchTakePictureIntent(isFinishingService);
        }//w w  w .  ja  v  a2  s  . c om
    });
    adb.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (isFinishingService) {
                finishIncident();
            }
            dialog.cancel();
        }
    });

    adb.show();
}

From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java

public void onWrongConnectionState(int state, final INotifiableManager manager, final Command<?> source) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    switch (state) {
    case WifiHelper.WIFI_STATE_DISABLED:
        builder.setTitle("Wifi disabled");
        builder.setMessage("This host is Wifi only. Should I activate Wifi?");
        builder.setNeutralButton("Activate Wifi", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                final ProgressDialog pd = new ProgressDialog(mActivity);
                pd.setCancelable(true);/*w  w w  .j a va2s  .  c  om*/
                pd.setTitle("Activating Wifi");
                pd.setMessage("Please wait while Wifi is activated.");
                pd.show();
                (new Thread() {
                    public void run() {
                        final WifiHelper helper = WifiHelper.getInstance(mActivity);
                        helper.enableWifi(true);
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_ENABLED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        manager.retryAll();
                        pd.cancel();
                        mDialogShowing = false;

                    }
                }).start();
            }
        });
        showDialog(builder);
        break;
    case WifiHelper.WIFI_STATE_ENABLED:
        final Host host = HostFactory.host;
        final WifiHelper helper = WifiHelper.getInstance(mActivity);
        final String msg;
        if (host != null && host.access_point != null && !host.access_point.equals("")) {
            helper.connect(host);
            msg = "Connecting to " + host.access_point + ". Please wait";
        } else {
            msg = "Waiting for Wifi to connect to your LAN.";
        }
        final ProgressDialog pd = new ProgressDialog(mActivity);
        pd.setCancelable(true);
        pd.setTitle("Connecting");
        pd.setMessage(msg);
        mWaitForWifi = new Thread() {
            public void run() {
                mDialogShowing = true;
                pd.show();
                (new Thread() {
                    public void run() {
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        pd.cancel();
                        mDialogShowing = false;
                    }
                }).start();
                pd.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(DialogInterface dialog) {
                        if (helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            builder.setTitle("Wifi doesn't seem to connect");
                            builder.setMessage(
                                    "You can open the Wifi settings or wait " + MAX_WAIT_FOR_WIFI + " seconds");
                            builder.setNeutralButton("Wifi Settings", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
                                }
                            });
                            builder.setCancelable(true);
                            builder.setNegativeButton("Wait", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.runOnUiThread(mWaitForWifi); //had to make the Thread a field because of this line
                                }
                            });

                            mActivity.runOnUiThread(new Runnable() {
                                public void run() {
                                    final AlertDialog alert = builder.create();
                                    try {
                                        if (!mDialogShowing) {
                                            alert.show();
                                            mDialogShowing = true;
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                        }
                    }

                });
            }
        };
        mActivity.runOnUiThread(mWaitForWifi);
    }

}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * @see android.app.Activity#onCreateDialog(int)
 *//*from w w w  . ja v  a  2 s.  c o  m*/
@Override
protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    switch (id) {
    case JSON_ERROR_DIALOG:
        builder.setTitle(R.string.cache_corrupt);
        builder.setMessage(R.string.cache_corrupt_message);
        builder.setNeutralButton(R.string.ok, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        return builder.create();
    case NO_SERVER_DIALOG:
        builder.setTitle(R.string.no_servers);
        builder.setMessage(R.string.no_server_message);
        builder.setPositiveButton(R.string.yes, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent addServer = new Intent(MCServerTrackerActivity.this, AddServerActivity.class);
                startActivityForResult(addServer, AddServerActivity.ADD_SERVER_ACTIVITY_ID);
            }
        });
        builder.setNegativeButton(R.string.no, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        return builder.create();
    case IO_ERROR_DIALOG:
        break;
    }
    return super.onCreateDialog(id);
}

From source file:com.sourcey.materiallogindemo.MainActivity.java

private void MessageDialog(String msg) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(msg).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();/*www .  j  a  v a2  s  . c  o m*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

private void showError(Intent intent) {
    final String errorMessage = intent.getStringExtra(ERROR_MESSAGE);
    if (TextUtils.isEmptyOrWhitespace(errorMessage)) {
        finish();//from  ww w.  j  av a2s .c o  m
        showErrorToast();
    } else {
        final String errorCaption = intent.getStringExtra(ERROR_CAPTION);
        final String errorAction = intent.getStringExtra(ERROR_ACTION);
        final String errorTitle = intent.getStringExtra(ERROR_TITLE);

        final AlertDialog.Builder builder = new AlertDialog.Builder(ProcessScanActivity.this);
        builder.setTitle(errorTitle);
        builder.setMessage(errorMessage);
        builder.setNegativeButton(R.string.rogerthat, new AlertDialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });

        if (!TextUtils.isEmptyOrWhitespace(errorCaption) && !TextUtils.isEmptyOrWhitespace(errorAction)) {
            builder.setPositiveButton(errorCaption, new AlertDialog.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(errorAction));
                    startActivity(intent);
                    dialog.dismiss();
                    finish();
                }
            });
        }

        builder.show();
    }
}

From source file:com.zira.registration.DocumentUploadActivity.java

@Override
public void processFinish(String output, String methodName) {
    // obj;/*ww  w.ja  v  a 2s  .c o  m*/
    //Log.e("doucment", output);
    if (methodName.equalsIgnoreCase(uploadImageMethod)) {
        Log.e("doucment", output);
        /*try {
           //JSONObject   obj = new JSONObject(output);
        //   String jsonMessage=obj.getString("message");
           //String jsonMessage1=obj.getString("result");
        //   System.err.println("messgage=="+jsonMessage+"result="+jsonMessage1);
        } catch (JSONException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }*/
    }
    if (methodName.equalsIgnoreCase(driverRegMethod)) {
        Log.e("driver update", output);
        try {
            JSONObject obj = new JSONObject(output);
            String jsonResult = obj.getString("result");
            String jsonMessage = obj.getString("message");

            if (jsonResult.equals("0")) {
                //Util.alertMessage(DocumentUploadActivity.this, jsonMessage);
                //editor.clear();
                //editor.commit();
                AlertDialog.Builder alert = new AlertDialog.Builder(DocumentUploadActivity.this);
                alert.setTitle("Zira24/7");
                alert.setMessage("Registration successful");

                alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        //System.err.println("messgage=="+jsonMessage+" "+jsonResult);
                        //            Toast.makeText(DocumentUploadActivity.this, jsonMessage, 1).show();
                        SingleTon.getInstance().setEdited(false);
                        mProfileInfoModel.setVechile_make(SingleTon.getInstance().getVehicleMake());
                        mProfileInfoModel.setVechile_model(SingleTon.getInstance().getVehicleModel());
                        mProfileInfoModel.setVechile_year(SingleTon.getInstance().getVehicleYear());
                        mProfileInfoModel
                                .setLicenseplatenumber(SingleTon.getInstance().getVehicleLicencePlateNumber());
                        mProfileInfoModel
                                .setLicenseplatecountry(SingleTon.getInstance().getVehicleCountryName());
                        mProfileInfoModel.setLicenseplatestate(SingleTon.getInstance().getVehicleStateName());
                        mProfileInfoModel.setAddress(SingleTon.getInstance().getBg_address1() + "");
                        mProfileInfoModel.setAddress1(SingleTon.getInstance().getBg_address1());
                        mProfileInfoModel.setAddress2("");//SingleTon.getInstance().getBg_address2());
                        mProfileInfoModel.setCity(SingleTon.getInstance().getBg_city());
                        mProfileInfoModel.setState(SingleTon.getInstance().getBg_drivingLicenseState());
                        mProfileInfoModel.setZipcode(SingleTon.getInstance().getBg_zipcode());
                        mProfileInfoModel
                                .setDrivinglicensenumber(SingleTon.getInstance().getBg_drivingLicenseNumber());
                        mProfileInfoModel
                                .setDrivinglicensestate(SingleTon.getInstance().getBg_drivingLicenseState());
                        mProfileInfoModel
                                .setDrivinglicenseexpirationdate(SingleTon.getInstance().getBg_LicExoDate());
                        mProfileInfoModel.setDateofbirth(SingleTon.getInstance().getBgDOB());
                        mProfileInfoModel
                                .setSocialsecuritynumber(SingleTon.getInstance().getBg_socialSecNumber());
                        SingleTon.getInstance().setProfileInfoModel(mProfileInfoModel);
                        getProfileInfo();
                        //finish();
                    }
                });
                alert.show();

                /*if(prefs.getString("mode", "").equals("rider"))
                {
                Intent i=new Intent(DocumentUploadActivity.this,VehicleSearchActivity.class);
                finish();
                startActivity(i);
                }
                else if(prefs.getString("mode", "").equals("driver"))
                {
                //Intent i=new Intent(DocumentUploadActivity.this,DriverModeActivity.class);
                finish();
                //startActivity(i);
                }*/

            } else {
                Util.alertMessage(DocumentUploadActivity.this, jsonMessage);
            }

        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
    if (methodName.equalsIgnoreCase(GetProfile)) {
        Log.e("getprofile=", output);
        mProfileInfoModel = ziraParser.profileInfo(output);
        SingleTon.getInstance().setProfileInfoModel(mProfileInfoModel);
        Intent i = new Intent(DocumentUploadActivity.this, GetProfile.class);
        startActivity(i);
        finish();

    }
}

From source file:it.sasabz.android.sasabus.InfoActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {

        @Override//  w w w  .jav  a 2  s .c  om
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    });
    Information information = (Information) list.get(position);
    builder.setTitle(Html.fromHtml(information.getTitel()));
    builder.setMessage(Html.fromHtml("<pre>" + information.getNachricht() + "</pre>"));
    builder.create().show();
}

From source file:com.googlecode.android_scripting.facade.ui.AlertDialogTask.java

@Override
public void onCreate() {
    super.onCreate();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    if (mTitle != null) {
        builder.setTitle(mTitle);/* ww  w  .j  ava 2s.  c o m*/
    }
    // Can't display both a message and items. We'll elect to show the items instead.
    if (mMessage != null && mItems.isEmpty()) {
        builder.setMessage(mMessage);
    }
    switch (mInputType) {
    // Add single choice menu items to dialog.
    case SINGLE_CHOICE:
        builder.setSingleChoiceItems(getItemsAsCharSequenceArray(), mSelectedItems.iterator().next(),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        mSelectedItems.clear();
                        mSelectedItems.add(item);
                    }
                });
        break;
    // Add multiple choice items to the dialog.
    case MULTI_CHOICE:
        boolean[] selectedItems = new boolean[mItems.size()];
        for (int i : mSelectedItems) {
            selectedItems[i] = true;
        }
        builder.setMultiChoiceItems(getItemsAsCharSequenceArray(), selectedItems,
                new DialogInterface.OnMultiChoiceClickListener() {
                    public void onClick(DialogInterface dialog, int item, boolean isChecked) {
                        if (isChecked) {
                            mSelectedItems.add(item);
                        } else {
                            mSelectedItems.remove(item);
                        }
                    }
                });
        break;
    // Add standard, menu-like, items to dialog.
    case MENU:
        builder.setItems(getItemsAsCharSequenceArray(), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                Map<String, Integer> result = new HashMap<String, Integer>();
                result.put("item", item);
                dismissDialog();
                setResult(result);
            }
        });
        break;
    case PLAIN_TEXT:
        mEditText = new EditText(getActivity());
        if (mDefaultText != null) {
            mEditText.setText(mDefaultText);
        }
        mEditText.setInputType(mEditInputType);
        builder.setView(mEditText);
        break;
    case PASSWORD:
        mEditText = new EditText(getActivity());
        mEditText.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
        mEditText.setTransformationMethod(new PasswordTransformationMethod());
        builder.setView(mEditText);
        break;
    default:
        // No input type specified.
    }
    configureButtons(builder, getActivity());
    addOnCancelListener(builder, getActivity());
    mDialog = builder.show();
    mShowLatch.countDown();
}

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

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

From source file:net.evecom.android.log.DailyLogAddActivity.java

/**
 * //  w  w w  .  j a v a 2s  .c om
 * 
 * @param errorMsg
 */
private void DialogToast(String errorMsg) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(DailyLogAddActivity.this);
    builder1.setTitle("");
    builder1.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder1.setMessage("" + errorMsg);
    builder1.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    builder1.show();
}