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:no.ntnu.idi.socialhitchhiking.map.MapActivityJourney.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    pickupPoint = getApp().getJourneyPickupPoint();
    dropoffPoint = getApp().getJourneyDropoffPoint();

    TextView driverView = (TextView) findViewById(R.id.mapViewJourneyDriver);
    TextView leaveTxt = (TextView) findViewById(R.id.leaveRideText);

    if (getApp().getUser().getFullName().equals(getApp().getSelectedJourney().getDriver().getFullName())) {
        leaveTxt.setText("Cancel ride");
    } else {//from   ww  w . ja va 2 s.  c  o m
        leaveTxt.setText("Leave ride");
    }

    if (pickupPoint != null) {
        drawCross(pickupPoint, true);
    }
    if (dropoffPoint != null) {
        drawCross(dropoffPoint, false);
    }
    driverView.setText(getApp().getSelectedJourney().getDriver().getFullName());

    if (getApp().getSelectedJourney().getHitchhikers().size() != 0) {

        TextView firstHitchTxt = (TextView) findViewById(R.id.firstHikerTxt);

        firstHitchTxt.setText(getApp().getSelectedJourney().getHitchhikers().get(0).getFullName());

        if (getApp().getSelectedJourney().getHitchhikers().size() > 1) {
            for (int c = 1; c < getApp().getSelectedJourney().getHitchhikers().size(); c++) {
                HitchList hitch = new HitchList(getApp().getSelectedJourney().getHitchhikers().get(c));
            }
        }

    } else {
        TextView firstHitchTxt = (TextView) findViewById(R.id.firstHikerTxt);
        firstHitchTxt.setText("No hitchhikers");
    }

    leaveRide = (FrameLayout) findViewById(R.id.leaveRide);
    leaveRide.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            AlertDialog.Builder ad = new AlertDialog.Builder(MapActivityJourney.this);
            if (getApp().getUser().getFullName()
                    .equals(getApp().getSelectedJourney().getDriver().getFullName())) {
                ad.setMessage("Do you want to cancel this ride?");
            } else {
                ad.setMessage("Do you want to leave this ride?");
            }
            ad.setTitle("Confirm");

            ad.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    handleJourney(getApp().getSelectedJourney());
                    MapActivityJourney.this.finish();
                }
            });
            ad.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                }
            });
            ad.show();

        }

    });

    btn = (FrameLayout) findViewById(R.id.mapViewJourneyBtn);
    btn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            sendMessageToDriver();
        }

    });

}

From source file:com.cloudkick.NodeViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.do_connectbot:
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String user = prefs.getString("sshUser", "root");
        Integer port = new Integer(prefs.getString("sshPort", "22"));
        String uri = "ssh://" + user + "@" + node.ipAddress + ":" + port + "/#" + user;
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        try {/*from  w w  w.  j  a v a  2 s .co  m*/
            startActivity(i);
        } catch (ActivityNotFoundException e) {
            // Suggest ConnectBot
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("SSH Client Not Found");
            String mfaMessage = ("The ConnectBot SSH Client is required to complete this operation. "
                    + "Would you like to install ConnectBot from the Android Market now?");
            builder.setMessage(mfaMessage);
            builder.setCancelable(true);
            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent marketActivity = new Intent(Intent.ACTION_VIEW);
                    marketActivity.setData(Uri.parse("market://details?id=org.connectbot"));
                    startActivity(marketActivity);
                }
            });
            builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            AlertDialog mfaDialog = builder.create();
            mfaDialog.show();
        }
        return true;
    default:
        // If its not recognized, do nothing
        return super.onOptionsItemSelected(item);
    }
}

From source file:jp.watnow.plugins.dialog.Notification.java

/**
 * //ww  w .  j a v a2  s .c om
 * @param message
 * @param title
 * @param buttonLabels
 * @param defaultTexts
 * @param callbackContext
 */
public synchronized void login(final String title, final String message, final JSONArray buttonLabels,
        final JSONArray defaultTexts, final CallbackContext callbackContext) {

    final CordovaInterface cordova = this.cordova;

    Runnable runnable = new Runnable() {
        public void run() {
            LinearLayout layout = new LinearLayout(cordova.getActivity());
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setPadding(10, 0, 10, 0);
            final EditText usernameInput = new EditText(cordova.getActivity());
            usernameInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
            final EditText passwordInput = new EditText(cordova.getActivity());
            passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            try {
                usernameInput.setHint("ID");
                usernameInput.setText(defaultTexts.getString(0));
                passwordInput.setHint("PASSWORD");
                passwordInput.setText(defaultTexts.getString(1));
            } catch (JSONException e1) {
            }

            layout.addView(usernameInput, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            layout.addView(passwordInput, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));

            AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            dlg.setView(layout);

            final JSONObject result = new JSONObject();

            try {
                dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        try {
                            result.put("buttonIndex", 1);
                            result.put("input1", usernameInput.getText());
                            result.put("input2", passwordInput.getText());
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                    }
                });
            } catch (JSONException e) {
            }

            try {
                dlg.setPositiveButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        try {
                            result.put("buttonIndex", 3);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                    }
                });
            } catch (JSONException e) {
            }

            dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    try {
                        result.put("buttonIndex", 0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                }
            });

            changeTextDirection(dlg);
        };
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:com.umeng.message.example.MainActivity.java

/**
 * //from  w  ww  .j  av  a 2 s . com
 * @param view
 */
public void upload(View view) {

    List<Map<String, Object>> all = pushDao.getAll();

    if (all.size() == 0) {
        Toast.makeText(this, "?", Toast.LENGTH_SHORT).show();
        return;
    }

    // ??
    final android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this);
    builder.setTitle("Upload");
    builder.setMessage("");
    builder.setCancelable(false);
    builder.setNegativeButton("", null);

    // 
    final Button btn = (Button) view;
    btn.setText("uploading ...");
    btn.setClickable(false);

    RequestParams params = new RequestParams();
    params.put("act", "upload_push_msg");
    params.put("data", gson.toJson(all));
    Log.e("jsondata", gson.toJson(all));

    new AsyncHttpClient().post("http://cms.orenda.com.cn:29055/upload_data", params,
            new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                    super.onSuccess(statusCode, headers, response);
                    String hasErrors = getString(response, "hasErrors");
                    if ("false".equals(hasErrors)) {
                        builder.setMessage("?");
                        pushDao.clear();
                    } else {
                        String msg = getString(response, "message");
                        Log.e("upload.hasError=true", msg);
                        builder.setMessage(msg);
                    }

                    btn.setText("UPLOAD");
                    btn.setClickable(true);
                    builder.show();
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, String responseString,
                        Throwable throwable) {
                    super.onFailure(statusCode, headers, responseString, throwable);
                    Log.e("onFailure1", String.valueOf(responseString) + "|" + throwable);
                    builder.show();
                    btn.setText("UPLOAD");
                    btn.setClickable(true);
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, Throwable throwable,
                        JSONArray errorResponse) {
                    super.onFailure(statusCode, headers, throwable, errorResponse);
                    Log.e("onFailure2", String.valueOf(errorResponse) + "|" + throwable);
                    builder.show();
                    btn.setText("UPLOAD");
                    btn.setClickable(true);
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, Throwable throwable,
                        JSONObject errorResponse) {
                    super.onFailure(statusCode, headers, throwable, errorResponse);
                    Log.e("onFailure3", String.valueOf(errorResponse) + "|" + throwable);
                    builder.show();
                    btn.setText("UPLOAD");
                    btn.setClickable(true);
                }
            });
}

From source file:com.remobile.dialogs.Notification.java

/**
 * Builds and shows a native Android alert with given Strings
 *
 * @param message         The message the alert should display
 * @param title           The title of the alert
 * @param buttonLabel     The label of the button
 * @param callbackContext The callback context
 *//*from w ww .j ava2  s .co m*/
public synchronized void alert(final String message, final String title, final String buttonLabel,
        final CallbackContext callbackContext) {
    Runnable runnable = new Runnable() {
        public void run() {

            AlertDialog.Builder dlg = createDialog(); // new AlertDialog.Builder(this.cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);
            dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
                }
            });
            dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
                }
            });

            changeTextDirection(dlg);
        }

        ;
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:com.irccloud.android.activity.PastebinsActivity.java

public void onIRCEvent(int what, Object o) {
    IRCCloudJSONObject obj;/*  w w  w .j  av a2s . com*/
    switch (what) {
    case NetworkConnection.EVENT_SUCCESS:
        obj = (IRCCloudJSONObject) o;
        if (obj.getInt("_reqid") == reqid) {
            Log.d("IRCCloud", "Pastebin deleted successfully");
            reqid = -1;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    adapter.pastebins.remove(pasteToDelete);
                    adapter.notifyDataSetChanged();
                    checkEmpty();
                    pasteToDelete = null;
                }
            });
        }
        break;
    case NetworkConnection.EVENT_FAILURE_MSG:
        obj = (IRCCloudJSONObject) o;
        if (reqid != -1 && obj.getInt("_reqid") == reqid) {
            Crashlytics.log(Log.ERROR, "IRCCloud", "Delete failed: " + obj.toString());
            reqid = -1;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    AlertDialog.Builder builder = new AlertDialog.Builder(PastebinsActivity.this);
                    builder.setTitle("Error");
                    builder.setMessage("Unable to delete this pastebin.  Please try again shortly.");
                    builder.setPositiveButton("Close", null);
                    builder.show();
                }
            });
        }
        break;
    default:
        break;
    }
}

From source file:fr.pasteque.client.Configure.java

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference.getKey().equals("printer_driver")) {
        // On printer driver update, change models
        if (newValue.equals("EPSON ePOS") && !Compat.isEpsonPrinterCompatible()) {
            Toast t = Toast.makeText(this, R.string.not_compatible, Toast.LENGTH_SHORT);
            t.show();/*from  w ww  .  ja  va  2s .co m*/
            return false;
        } else if ((newValue.equals("LK-PXX") && !Compat.isLKPXXPrinterCompatible())
                || (newValue.equals("Woosim") && !Compat.isWoosimPrinterCompatible())) {
            Toast t = Toast.makeText(this, R.string.not_compatible, Toast.LENGTH_SHORT);
            t.show();
            return false;
        }
        this.updatePrinterPrefs(newValue);
    } else if ("card_processor".equals(preference.getKey())) {
        if ("payleven".equals(newValue) && !Compat.hasPaylevenApp(this)) {
            // Trying to enable payleven without app: download
            AlertDialog.Builder b = new AlertDialog.Builder(this);
            b.setTitle(R.string.config_payleven_download_title);
            b.setMessage(R.string.config_payleven_download_message);
            b.setIcon(android.R.drawable.ic_dialog_info);
            b.setNegativeButton(android.R.string.cancel, null);
            b.setPositiveButton(R.string.config_payleven_download_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=de.payleven.androidphone"));
                    Configure.this.startActivity(i);
                }
            });
            b.show();
            return false;
        }
        this.updateCardProcessorPreferences((String) newValue);
    }
    return true;
}

From source file:com.spydiko.rotationmanager.MainActivity.java

public void showPlayStoreDialog(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // Add the buttons
    builder.setTitle("Spydiko");
    builder.setMessage(R.string.landing_msg);
    builder.setIcon(R.drawable.icon);/*  w  ww.jav a  2s.  c  om*/
    builder.setPositiveButton(R.string.playStore, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User clicked OK button
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://search?q=pub:Spydiko"));
            startActivity(intent);
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User cancelled the dialog
        }
    });
    // Set other dialog properties

    // Create the AlertDialog
    AlertDialog dialog = builder.create();
    //      AppSpecificOrientation.ALREADY_SHOWED = true;
    //      AppSpecificOrientation.RETURN_FROM_ABOUT = false;
    dialog.show();
}

From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java

private void registerWithQRUrl(final String qr_url) {
    if (!mService.getNetworkConnectivityManager().isConnected()) {
        UIUtils.showNoNetworkDialog(this);
        return;/*from  w w  w  .  ja va2 s.  c  om*/
    }

    final String timestamp = "" + mWiz.getTimestamp();
    final String deviceId = mWiz.getDeviceId();
    final String registrationId = mWiz.getRegistrationId();
    final String installId = mWiz.getInstallationId();
    // Make call to Rogerthat webfarm

    mProgressContainer.setVisibility(View.VISIBLE);
    mButtonContainer.setVisibility(View.GONE);

    final SafeRunnable showErrorDialog = new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.UI();
            mProgressContainer.setVisibility(View.GONE);
            mButtonContainer.setVisibility(View.VISIBLE);
            AlertDialog.Builder builder = new AlertDialog.Builder(ContentBrandingRegistrationActivity.this);
            builder.setMessage(R.string.error_please_try_again);
            builder.setPositiveButton(R.string.rogerthat, null);
            AlertDialog dialog = builder.create();
            dialog.show();
        }
    };

    mWorkerHandler.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.REGISTRATION();
            String version = "1";
            String signature = Security.sha256(version + " " + installId + " " + timestamp + " " + deviceId
                    + " " + registrationId + " " + qr_url + CloudConstants.REGISTRATION_MAIN_SIGNATURE);

            HttpPost httppost = new HttpPost(CloudConstants.REGISTRATION_QR_URL);
            try {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(13);
                nameValuePairs.add(new BasicNameValuePair("version", version));
                nameValuePairs.add(new BasicNameValuePair("platform", "android"));
                nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp));
                nameValuePairs.add(new BasicNameValuePair("device_id", deviceId));
                nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId));
                nameValuePairs.add(new BasicNameValuePair("signature", signature));
                nameValuePairs.add(new BasicNameValuePair("install_id", installId));
                nameValuePairs.add(new BasicNameValuePair("qr_url", qr_url));
                nameValuePairs.add(new BasicNameValuePair("language", Locale.getDefault().getLanguage()));
                nameValuePairs.add(new BasicNameValuePair("country", Locale.getDefault().getCountry()));
                nameValuePairs.add(new BasicNameValuePair("app_id", CloudConstants.APP_ID));
                nameValuePairs.add(
                        new BasicNameValuePair("use_xmpp_kick", CloudConstants.USE_XMPP_KICK_CHANNEL + ""));
                nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", mGCMRegistrationId));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                // Execute HTTP Post Request
                HttpResponse response = mHttpClient.execute(httppost);

                int statusCode = response.getStatusLine().getStatusCode();
                HttpEntity entity = response.getEntity();

                if (entity == null) {
                    mUIHandler.post(showErrorDialog);
                    return;
                }

                @SuppressWarnings("unchecked")
                final Map<String, Object> responseMap = (Map<String, Object>) JSONValue
                        .parse(new InputStreamReader(entity.getContent()));

                if (statusCode != 200 || responseMap == null) {
                    if (statusCode == 500 && responseMap != null) {
                        final String errorMessage = (String) responseMap.get("error");
                        if (errorMessage != null) {
                            mUIHandler.post(new SafeRunnable() {
                                @Override
                                protected void safeRun() throws Exception {
                                    T.UI();
                                    mProgressContainer.setVisibility(View.GONE);
                                    mButtonContainer.setVisibility(View.VISIBLE);
                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                            ContentBrandingRegistrationActivity.this);
                                    builder.setMessage(errorMessage);
                                    builder.setPositiveButton(R.string.rogerthat, null);
                                    AlertDialog dialog = builder.create();
                                    dialog.show();
                                }
                            });
                            return;
                        }
                    }
                    mUIHandler.post(showErrorDialog);
                    return;
                }
                JSONObject account = (JSONObject) responseMap.get("account");
                final String email = (String) responseMap.get("email");
                final RegistrationInfo info = new RegistrationInfo(email,
                        new Credentials((String) account.get("account"), (String) account.get("password")));
                mUIHandler.post(new SafeRunnable() {
                    @Override
                    protected void safeRun() throws Exception {
                        T.UI();
                        mWiz.setEmail(email);
                        mWiz.save();
                        tryConnect(1, getString(R.string.registration_establish_connection, email,
                                getString(R.string.app_name)) + " ", info);
                    }
                });

            } catch (Exception e) {
                L.d(e);
                mUIHandler.post(showErrorDialog);
            }
        }
    });
}

From source file:jp.watnow.plugins.dialog.Notification.java

/**
 * Builds and shows a native Android prompt dialog with given title, message, buttons.
 * This dialog only shows up to 3 buttons.  Any labels after that will be ignored.
 * The following results are returned to the JavaScript callback identified by callbackId:
 *     buttonIndex         Index number of the button selected
 *     input1            The text entered in the prompt dialog box
 *
 * @param message           The message the dialog should display
 * @param title             The title of the dialog
 * @param buttonLabels      A comma separated list of button labels (Up to 3 buttons)
 * @param callbackContext   The callback context.
 *///w  w w.j a  va 2  s.  c  o m
public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels,
        final String defaultText, final String dialogType, final CallbackContext callbackContext) {

    final CordovaInterface cordova = this.cordova;

    Runnable runnable = new Runnable() {
        public void run() {
            final EditText promptInput = new EditText(cordova.getActivity());
            promptInput.setHint(defaultText);
            Log.d("DialogPlugin", dialogType);
            if (dialogType.equals(INPUT_SECURE)) {
                promptInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }
            AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            dlg.setView(promptInput);

            final JSONObject result = new JSONObject();

            // First button
            if (buttonLabels.length() > 0) {
                try {
                    dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            try {
                                result.put("buttonIndex", 1);
                                result.put("input1",
                                        promptInput.getText().toString().trim().length() == 0 ? defaultText
                                                : promptInput.getText());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                        }
                    });
                } catch (JSONException e) {
                }
            }

            // Second button
            if (buttonLabels.length() > 1) {
                try {
                    dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            try {
                                result.put("buttonIndex", 2);
                                result.put("input1",
                                        promptInput.getText().toString().trim().length() == 0 ? defaultText
                                                : promptInput.getText());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                        }
                    });
                } catch (JSONException e) {
                }
            }

            // Third button
            if (buttonLabels.length() > 2) {
                try {
                    dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            try {
                                result.put("buttonIndex", 3);
                                result.put("input1",
                                        promptInput.getText().toString().trim().length() == 0 ? defaultText
                                                : promptInput.getText());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                        }
                    });
                } catch (JSONException e) {
                }
            }
            dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    try {
                        result.put("buttonIndex", 0);
                        result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText
                                : promptInput.getText());
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                }
            });

            changeTextDirection(dlg);
        };
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}