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.hichinaschool.flashcards.anki.multimediacard.activity.MultimediaCardEditorActivity.java

private void delete() {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override//from  w w  w  .ja  v a2 s. co  m
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                if (mAddNote) {
                    finish();
                } else {
                    // Do not really delete the node here, instead let
                    // the caller deal with deletion.
                    // FIXME: Since only CardBrowser calls us,
                    // CardBrowser handles deletion and Listview Update
                    setResult(RESULT_DELETED);
                    finish();
                }
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                // Do nothing
                break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(gtxt(R.string.multimedia_editor_activity_delete_question))
            .setPositiveButton(gtxt(R.string.multimedia_editor_activity_delete_confirm), dialogClickListener)
            .setNegativeButton(gtxt(R.string.multimedia_editor_activity_delete_reject), dialogClickListener)
            .show();
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

public void deleteBeacon(int position) {
    final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr();

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("  ?");
    alertDialog.setMessage("? ? ?");
    alertDialog.setIcon(R.drawable.alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            updateEvent("BEACON_DELETE");
            DeleteBeacon deleteBeacon = new DeleteBeacon();
            deleteBeacon.execute("http://125.131.73.198:3000/beconDelete", beaconmac);
        }/*from ww w  .  j ava2 s  . c om*/
    });

    alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.show();
}

From source file:com.otaupdater.OTAUpdaterActivity.java

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

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);//  w  w w .  java 2s  .co m

    if (!cfg.hasProKey()) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                billingSrvConn = new ServiceConnection() {
                    @Override
                    public void onServiceDisconnected(ComponentName name) {
                        billingSrvConn = null;
                    }

                    @Override
                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder);

                        try {
                            Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null);
                            ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                            ArrayList<String> ownedItemData = owned
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                            if (ownedItems != null && ownedItemData != null) {
                                for (int q = 0; q < ownedItems.size(); q++) {
                                    if (ownedItems.get(q).equals(Config.PROKEY_SKU)) {
                                        JSONObject itemData = new JSONObject(ownedItemData.get(q));
                                        cfg.setKeyPurchaseToken(itemData.getString("purchaseToken"));
                                        break;
                                    }
                                }
                            }
                        } catch (RemoteException ignored) {
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        unbindService(this);
                        billingSrvConn = null;
                    }
                }, Context.BIND_AUTO_CREATE);
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.alert_unsupported_title);
        builder.setMessage(R.string.alert_unsupported_message);
        builder.setCancelable(false);
        builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cfg.setIgnoredUnsupportedWarn(true);
                dialog.dismiss();
            }
        });

        final AlertDialog dlg = builder.create();

        dlg.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                onDialogShown(dlg);
            }
        });
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                onDialogClosed(dlg);
            }
        });
        dlg.show();
    }

    setContentView(R.layout.main);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate())
        kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class);

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
            cfg.getStoredKernelUpdate().showUpdateNotif(this);
        }

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}

From source file:palamarchuk.smartlife.app.RegisterActivity.java

private void startRegisterProcess(String deviceKey) {
    String url = ServerRequest.DOMAIN + "/users";
    MultipartEntity multipartEntity;//  w ww .j  a  va 2s. c  o  m

    // collect data
    try {
        multipartEntity = collectData();
        multipartEntity.addPart("token", new StringBody(deviceKey));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    QueryMaster queryMaster = new QueryMaster(RegisterActivity.this, url, QueryMaster.QUERY_POST,
            multipartEntity);
    queryMaster.setProgressDialog();

    queryMaster.setOnCompleteListener(new QueryMaster.OnCompleteListener() {
        @Override
        public void complete(String serverResponse) {
            try {
                JSONObject jsonObject = new JSONObject(serverResponse);
                String status = jsonObject.getString("status");

                if (status.equalsIgnoreCase(ServerRequest.STATUS_SUCCESS)) {
                    Toast.makeText(RegisterActivity.this, "??  ?",
                            Toast.LENGTH_SHORT).show();

                    SharedPreferences.Editor editor = sharedPreferences.edit();
                    editor.putString(SHARED_PREF_PHONE, phone.getText().toString());
                    editor.putString(SHARED_PREF_PASSWORD, password.getText().toString());
                    editor.apply();

                    AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
                    builder.setMessage(
                            "?      ?? ?,    ");
                    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            //                                startLoginActivityAutoStart(RegisterActivity.this);
                            Intent loginActivity = new Intent(RegisterActivity.this, LoginActivity.class);
                            loginActivity.putExtra(LoginActivity.SMS_VERIFICATION, true);
                            loginActivity.putExtra(LoginActivity.AUTOLOGIN, true);

                            startActivity(loginActivity);
                            finish();
                        }
                    });
                    builder.show();

                } else if (status.equalsIgnoreCase(ServerRequest.STATUS_ERROR)) {
                    if (jsonObject.has(ServerRequest.SMS_VERIFICATION_ERROR)) {
                        int verificationErrorCode = jsonObject.getInt(ServerRequest.SMS_VERIFICATION_ERROR);

                        if (verificationErrorCode == 1) {
                            AlertDialog.Builder pleaseTryLogin = new AlertDialog.Builder(RegisterActivity.this);
                            pleaseTryLogin.setMessage(jsonObject.getString("message"));
                            pleaseTryLogin.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    startLoginActivityAutoStart(RegisterActivity.this);
                                }
                            });
                            pleaseTryLogin.show();
                        }
                    } else {
                        Toast.makeText(RegisterActivity.this, jsonObject.getString("message"),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            } catch (JSONException ex) {
                ex.printStackTrace();
                throw new RuntimeException("Server response cannot be cast to JSONObject");
            }
        }

        @Override
        public void error(int errorCode) {
            Toast.makeText(RegisterActivity.this,
                    " ?!   ?  !",
                    Toast.LENGTH_SHORT).show();
        }
    });
    queryMaster.start();
}

From source file:se.anyro.tagtider.TransferActivity.java

private AlertDialog createSmsDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.sms_dialog_title);
    if (mPhoneNumber == null) {
        builder.setMessage(R.string.sms_dialog_message);
    } else {/*from www. java 2  s .  c o m*/
        builder.setMessage(String.format(getString(R.string.sms_dialog_message_free), mPhoneNumber));
    }
    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mPhoneNumber == null) {
                sendSms("0730121096", mTrain + " " + mStationId);
            } else {
                new StartSubscriptionTask().execute(mPhoneNumber, TYPE_SMS);
            }
        }
    });
    builder.setNegativeButton("Avbryt", null);
    final AlertDialog smsDialog = builder.create();
    return smsDialog;
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

private void updateUseBeacon(int usingPosition, int position) {
    final String usingBeaconmac = mMyDeviceAdapter.getDeviceList().get(usingPosition).getBdAddr();
    final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr();

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("  ?");
    alertDialog.setMessage("? ? ?");
    alertDialog.setIcon(R.drawable.alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            updateEvent("BEACON_USE");
            UpdateUseBeacon updateUseBeacon = new UpdateUseBeacon();
            updateUseBeacon.execute("http://125.131.73.198:3000/beaconUseUpdate", usingBeaconmac, beaconmac);
        }// w  ww  . j a v a 2  s.c  om
    });

    alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    alertDialog.show();

}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

public void useBeacon(int position) {
    final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr();

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("  ?");
    alertDialog.setMessage("? ? ?");
    alertDialog.setIcon(R.drawable.alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            updateEvent("BEACON_USE");
            UseBeacon useBeacon = new UseBeacon();
            useBeacon.execute("http://125.131.73.198:3000/beaconUse", beaconmac);

        }// ww  w  .  j  a  v  a 2  s.c  om
    });

    // Setting Negative "NO" Button
    alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to invoke NO event
            dialog.cancel();
        }
    });

    // Showing Alert Message
    alertDialog.show();
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

private void stopUseBeacon(int position) {
    final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr();

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("   ?");
    alertDialog.setMessage("? ?   ?");
    alertDialog.setIcon(R.drawable.alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            updateEvent("BEACON_STOP");
            StopUseBeacon stopUseBeacon = new StopUseBeacon();
            stopUseBeacon.execute("http://125.131.73.198:3000/beaconStop", beaconmac);
        }/*from ww w.  ja  v  a  2  s .c o  m*/
    });

    alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.show();
}

From source file:com.wirelessmoves.cl.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case RESET_COUNTER:

        NumberOfCellChanges = 0;/* ww w.j a v a2s .  c  o  m*/
        NumberOfLacChanges = 0;
        NumberOfSignalStrengthUpdates = 0;

        NumberOfUniqueCellChanges = 0;

        /* Initialize PreviousCells Array to a defined value */
        for (int x = 0; x < PreviousCells.length; x++)
            PreviousCells[x] = 0;

        return true;

    case ABOUT:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(
                "Cell Logger\r\n2012, Martin Sauter\r\n2014, rong zedong.\r\nhttp://www.wirelessmoves.com")
                .setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

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

        return true;

    case TOGGLE_DEBUG:
        /* Toggle the debug behavior of the program when the user selects this menu item */
        if (outputDebugInfo == false) {
            outputDebugInfo = true;
        } else {
            outputDebugInfo = false;
        }

        return true;

    default:
        return super.onOptionsItemSelected(item);

    }
}

From source file:com.remobile.dialogs.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 v a  2s.c om*/
public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels,
        final String defaultText, final CallbackContext callbackContext) {
    final Activity activity = this.cordova.getActivity();
    Runnable runnable = new Runnable() {
        public void run() {
            final EditText promptInput = new EditText(activity);
            promptInput.setHint(defaultText);
            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.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);
}