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:org.openhab.habdroid.ui.OpenHABRoomSettingActivity.java

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

From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java

/**
 * Show dialog error/*  w  w  w .j  a va  2  s. c  o m*/
 * @param errStr
 */
public void showDialogInformation(String errStr) {
    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setIcon(R.drawable.icon);
    adb.setTitle(R.string.str_ErrPlay_Title);
    adb.setMessage(errStr);
    adb.setPositiveButton(R.string.str_OK, new OnClickListener() {
        public void onClick(DialogInterface a0, int a1) {
            return;
        }
    });
    AlertDialog ad = adb.create();
    ad.show();
}

From source file:com.mobicage.rogerthat.plugins.messaging.AttachmentViewerActivity.java

@SuppressLint({ "SetJavaScriptEnabled" })
protected void updateView(boolean isUpdate) {
    T.UI();//from   w  ww.  j ava  2s. com

    if (!isUpdate && mGenerateThumbnail) {
        File thumbnail = new File(mFile.getAbsolutePath() + ".thumb");
        if (!thumbnail.exists()) {
            boolean isImage = mContentType.toLowerCase(Locale.US).startsWith("image/");
            boolean isVideo = !isImage && mContentType.toLowerCase(Locale.US).startsWith("video/");
            try {
                // Try to generate a thumbnail
                mMessagingPlugin.createAttachmentThumbnail(mFile.getAbsolutePath(), isImage, isVideo);
            } catch (Exception e) {
                L.e("Failed to generate attachment thumbnail", e);
            }
        }
    }

    final String fileOnDisk = "file://" + mFile.getAbsolutePath();

    if (mContentType.toLowerCase(Locale.US).startsWith("video/")) {
        MediaController mediacontroller = new MediaController(this);
        mediacontroller.setAnchorView(mVideoview);

        Uri video = Uri.parse(fileOnDisk);
        mVideoview.setMediaController(mediacontroller);
        mVideoview.setVideoURI(video);

        mVideoview.requestFocus();
        mVideoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mVideoview.start();
            }
        });

        mVideoview.setOnErrorListener(new MediaPlayer.OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer mp, int what, int extra) {
                L.e("Could not play video, what " + what + ", extra " + extra + ", content_type " + mContentType
                        + ", and url " + mDownloadUrl);

                AlertDialog.Builder builder = new AlertDialog.Builder(AttachmentViewerActivity.this);
                builder.setMessage(R.string.error_please_try_again);
                builder.setCancelable(true);
                builder.setTitle(null);
                builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        dialog.dismiss();
                        finish();
                    }
                });
                builder.setPositiveButton(R.string.rogerthat, new SafeDialogInterfaceOnClickListener() {
                    @Override
                    public void safeOnClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                });
                builder.create().show();
                return true;
            }
        });

    } else if (CONTENT_TYPE_PDF.equalsIgnoreCase(mContentType)) {
        WebSettings settings = mWebview.getSettings();
        settings.setJavaScriptEnabled(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            settings.setAllowUniversalAccessFromFileURLs(true);
        }

        mWebview.setWebViewClient(new WebViewClient() {

            @Override
            public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
                if (fileOnDisk.equals(url)) {
                    return null;
                }
                L.d("404: Expected: '" + fileOnDisk + "'\n Received: '" + url + "'");
                return new WebResourceResponse("text/plain", "UTF-8", null);
            }
        });
        try {
            mWebview.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file="
                    + URLEncoder.encode(fileOnDisk, "UTF-8"));
        } catch (UnsupportedEncodingException uee) {
            L.bug(uee);
        }
    } else {
        WebSettings settings = mWebview.getSettings();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            settings.setAllowFileAccessFromFileURLs(true);
        }
        settings.setBuiltInZoomControls(true);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);

        if (mContentType.toLowerCase(Locale.US).startsWith("image/")) {
            String html = "<html><head></head><body><img style=\"width: 100%;\" src=\"" + fileOnDisk
                    + "\"></body></html>";
            mWebview.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
        } else {
            mWebview.loadUrl(fileOnDisk);
        }
    }
    L.d("File on disk: " + fileOnDisk);
}

From source file:com.google.zxing.client.android.CaptureActivity.java

private void displayFrameworkBugMessageAndExit() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(EUExUtil.getResStringID("app_name")));
    builder.setMessage(getString(EUExUtil.getResStringID("plugin_uexscanner_msg_camera_framework_bug")));
    builder.setPositiveButton(EUExUtil.getResStringID("confirm"), new FinishListener(this));
    builder.setOnCancelListener(new FinishListener(this));
    builder.show();//  w  ww. j ava2  s. c o  m
}

From source file:com.t2.androidspineexample.AndroidSpineExampleActivity.java

/**
 * Validates sensors, makes sure that bluetooth is on and each sensor has a parameter associated with it
 *///  w  ww  .j a v a2 s.  co m
void validateBioSensors() {

    // First make sure that bluetooth is enabled
    if (!mBluetoothEnabled) {
        AlertDialog.Builder alert1 = new AlertDialog.Builder(this);

        alert1.setMessage("Bluetooth is not enabled on your device.");

        alert1.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
            }
        });
        alert1.show();
    }
    String badSensorName = null;
}

From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_save:
        Database.init(getApplicationContext());
        Database.setEmail(email);//  w  w  w  .  java 2 s  .  co  m

        if (getMathAlarm().getId() < 1) {
            getMathAlarm().setEmail(email);
            Database.create(getMathAlarm());
            Bundle bundle = getIntent().getExtras();
            if (bundle != null && bundle.containsKey("user")) {
                User user = (User) bundle.getSerializable("user");
                Group group = new Group(getMathAlarm(), user);
                Database.addGroup(group);
            }
            params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("email", email));
            Log.d("??? ? : ", "" + email);
            params.add(new BasicNameValuePair("time", getMathAlarm().getAlarmTimeString()));
            params.add(new BasicNameValuePair("difficulty",
                    Integer.toString(getMathAlarm().getDifficulty().ordinal())));
            params.add(new BasicNameValuePair("tone", getMathAlarm().getAlarmTonePath()));
            params.add(new BasicNameValuePair("vibrate", Boolean.toString(getMathAlarm().getVibrate())));
            params.add(new BasicNameValuePair("name", getMathAlarm().getAlarmName()));
            //params.add(new BasicNameValuePair("days", Arrays.toString(getMathAlarm().getDays())));
            for (int i = 0; i < getMathAlarm().getDays().length; i++) {
                params.add(new BasicNameValuePair("days", getMathAlarm().getDays()[i].toString()));
            }
            ServerRequest sr = new ServerRequest();
            JSONObject json = sr.getJSON("http://168.188.123.218:8080/alarmdata", params);
            if (json != null) {
                try {
                    String jsonstr = json.getString("response");
                    //JSONObject json2 = sr.getJSON("http://168.188.123.218:8080/useralarm", params);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else {
            Database.update(getMathAlarm());
            Database.setEmail(email);

        }

        callMathAlarmScheduleService();
        Toast.makeText(AlarmPreferencesActivity.this, getMathAlarm().getTimeUntilNextAlarmMessage(),
                Toast.LENGTH_LONG).show();
        finish();
        break;
    case R.id.menu_item_delete:
        AlertDialog.Builder dialog = new AlertDialog.Builder(AlarmPreferencesActivity.this);
        dialog.setTitle("Delete");
        dialog.setMessage("Delete this alarm?");
        dialog.setPositiveButton("Ok", new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                Database.init(getApplicationContext());
                Database.setEmail(email);

                if (getMathAlarm().getId() < 1) {
                    // Alarm not saved
                } else {
                    params = new ArrayList<NameValuePair>();
                    params.add(new BasicNameValuePair("email", email));
                    params.add(new BasicNameValuePair("time", alarm.getAlarmTimeString()));
                    Log.d("??? ? : ", "" + email);
                    ServerRequest sr = new ServerRequest();
                    JSONObject json = sr.getJSON("http://168.188.123.218:8080/deletealarm", params);

                    Database.deleteEntry(alarm);
                    callMathAlarmScheduleService();
                }
                finish();
            }
        });
        dialog.setNegativeButton("Cancel", new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.show();

        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:fi.mikuz.boarder.gui.internet.Uploads.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    final InternetFullBoard board = ((BoardListAdapter) mListView.getAdapter()).getItem(position);

    if (!board.getUploaderUsername().equals("")) {
        final CharSequence[] items = { "Edit", "Delete" };

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(board.getBoardName());
        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                if (item == 0) {
                    boardUploader(board, InternetMenu.PHP_OPERATION_EDIT);
                } else if (item == 1) {
                    AlertDialog.Builder deleteBuilder = new AlertDialog.Builder(Uploads.this);
                    deleteBuilder.setTitle("Deleting upload");
                    deleteBuilder.setMessage("Are you sure you want to permanently delete upload '"
                            + board.getBoardName() + "'?");

                    deleteBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            HashMap<String, String> sendList = new HashMap<String, String>();
                            sendList.put(InternetMenu.UPLOADER_ID_KEY, mUserId);
                            sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                            sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(board.getBoardId()));
                            new ConnectionManager(Uploads.this, InternetMenu.mDeleteUploadedBoardURL, sendList);
                        }/*from   w w w . j  av a  2s .co  m*/
                    });
                    deleteBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.dismiss();
                        }
                    });
                    AlertDialog deleteAlert = deleteBuilder.create();
                    deleteAlert.show();
                }
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:org.dvbviewer.controller.ui.fragments.RecordingList.java

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menuDelete:
        /**/*from  w  w w.  jav a2  s  . c  om*/
         * Alertdialog to confirm the delete of Recordings
         */
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(getResources().getString(R.string.confirmDelete))
                .setPositiveButton(getResources().getString(R.string.yes), this)
                .setNegativeButton(getResources().getString(R.string.no), this).show();
        break;

    default:
        break;
    }
    return true;
}

From source file:org.starfishrespect.myconsumption.android.ui.ChartChoiceFragment.java

private void deleteSensor(int index) {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setTitle(R.string.dialog_title_confirmation);
    builder.setMessage(
            String.format(getResources().getString(R.string.dialog_message_confirmation_delete_sensor),
                    sensors.get(lastLongClickItem).getName()));
    builder.setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
        @Override/*from   ww  w. j a v  a  2  s . co  m*/
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            new AsyncTask<Void, Boolean, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    RestTemplate template = new RestTemplate();
                    HttpHeaders httpHeaders = CryptoUtils.createHeadersCurrentUser();
                    template.getMessageConverters().add(new FormHttpMessageConverter());
                    template.getMessageConverters().add(new StringHttpMessageConverter());

                    String url = SingleInstance.getServerUrl() + "users/"
                            + SingleInstance.getUserController().getUser().getName() + "/sensor/"
                            + sensors.get(lastLongClickItem).getSensorId();

                    template.exchange(url, HttpMethod.DELETE, new HttpEntity<>(httpHeaders), String.class);

                    try {
                        SingleInstance.getDatabaseHelper().getSensorDao()
                                .delete(sensors.get(lastLongClickItem));
                        new SensorValuesDao(SingleInstance.getDatabaseHelper())
                                .removeSensor(sensors.get(lastLongClickItem).getSensorId());
                    } catch (SQLException e) {
                        publishProgress(false);
                    }
                    publishProgress(true);
                    return null;
                }

                @Override
                protected void onProgressUpdate(Boolean... values) {
                    for (boolean b : values) {
                        if (b) {
                            new AlertDialog.Builder(mActivity).setTitle(R.string.dialog_title_information)
                                    .setMessage(R.string.dialog_message_information_sensor_deleted)
                                    .setPositiveButton(R.string.button_ok,
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialog, int which) {
                                                    EventBus.getDefault().post(new ReloadUserEvent(false));
                                                    dialog.dismiss();
                                                }
                                            })
                                    .show();
                        } else {
                            new AlertDialog.Builder(mActivity).setTitle(R.string.dialog_title_information)
                                    .setMessage("unknown error while deleting from DB").setPositiveButton(
                                            R.string.button_ok, new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialog, int which) {
                                                    dialog.dismiss();
                                                }
                                            })
                                    .show();
                        }
                    }
                }
            }.execute();
            dialog.dismiss();
        }

    });
    builder.show();

}

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

private void DialogMap() {
    View dialogBoxView = View.inflate(this, R.layout.activity_map, null);
    final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView);

    String url = getString(R.string.url_map) + "index.php?poinFrom=" + txtStart.getText().toString().trim()
            + "&poinTo=" + txtEnd.getText().toString().trim();

    map.getSettings().setLoadsImagesAutomatically(true);
    map.getSettings().setJavaScriptEnabled(true);
    map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    map.loadUrl(url);/*from  w  w w  .  j  a v a2 s. c om*/

    AlertDialog.Builder builderInOut = new AlertDialog.Builder(this);
    builderInOut.setTitle("Map");
    builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false)
            .setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).show();
}