src/android/Notification.java
/**
     * Builds and shows a native Android confirm dialog with given title, message, buttons.
     * This dialog only shows up to 3 buttons.  Any labels after that will be ignored.
     * The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
     *
     * @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.
     */
Builds and shows a native Android confirm dialog with given title, message, buttons.
This dialog only shows up to 3 buttons.  Any labels after that will be ignored.
The index of the button pressed will be returned to the JavaScript callback identified by callbackId.

@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.
Builds and shows a native Android confirm dialog with given title message buttons . This dialog only shows up to 3 buttons . Any labels after that will be ignored . The index of the button pressed will be returned to the JavaScript callback identified by callbackId . @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 .
public synchronized void confirm(final String message, final String title, final JSONArray buttonLabels, final CallbackContext callbackContext) {
    	final CordovaInterface cordova = this.cordova;
        Runnable runnable = new Runnable() {
            public void run() {
                Builder dlg = createDialog(cordova); 
                dlg.setMessage(message);
                dlg.setTitle(title);
                dlg.setCancelable(true);
                if (buttonLabels.length() > 0) {
                    try {
                        dlg.setNegativeButton(buttonLabels.getString(0),
                            new AlertDialog.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
                                }
                            });
                    } catch (JSONException e) {
                        LOG.d(LOG_TAG,"JSONException on first button.");
                    }
                }
                if (buttonLabels.length() > 1) {
                    try {
                        dlg.setNeutralButton(buttonLabels.getString(1),
                            new AlertDialog.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
                                }
                            });
                    } catch (JSONException e) {
                        LOG.d(LOG_TAG,"JSONException on second button.");
                    }
                }
                if (buttonLabels.length() > 2) {
                    try {
                        dlg.setPositiveButton(buttonLabels.getString(2),
                            new AlertDialog.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                  dialog.dismiss();
                                  callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
                                }
                            });
                    } catch (JSONException e) {
                        LOG.d(LOG_TAG,"JSONException on third button.");
                    }
                }
                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);
    }
public synchronized void confirm ( final String message , final String title , final JSONArray buttonLabels , final CallbackContext callbackContext ) { final CordovaInterface cordova = this . cordova ; Runnable runnable = new Runnable ( ) { public void run ( ) { Builder dlg = createDialog ( cordova ) ; dlg . setMessage ( message ) ; dlg . setTitle ( title ) ; dlg . setCancelable ( true ) ; if ( buttonLabels . length ( ) > 0 ) { try { dlg . setNegativeButton ( buttonLabels . getString ( 0 ) , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; callbackContext . sendPluginResult ( new PluginResult ( PluginResult . Status . OK , 1 ) ) ; } } ) ; } catch ( JSONException e ) { LOG . d ( LOG_TAG , "JSONException on first button." ) ; } } if ( buttonLabels . length ( ) > 1 ) { try { dlg . setNeutralButton ( buttonLabels . getString ( 1 ) , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; callbackContext . sendPluginResult ( new PluginResult ( PluginResult . Status . OK , 2 ) ) ; } } ) ; } catch ( JSONException e ) { LOG . d ( LOG_TAG , "JSONException on second button." ) ; } } if ( buttonLabels . length ( ) > 2 ) { try { dlg . setPositiveButton ( buttonLabels . getString ( 2 ) , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; callbackContext . sendPluginResult ( new PluginResult ( PluginResult . Status . OK , 3 ) ) ; } } ) ; } catch ( JSONException e ) { LOG . d ( LOG_TAG , "JSONException on third button." ) ; } } 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 ) ; }
Builds and shows a native Android confirm dialog with given title, message, buttons.
Builds and shows a native Android confirm dialog with given title message buttons .
// new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); // First button // Second button // Third button