Java Code Examples for android.support.v7.app.AlertDialog#setMessage()

The following examples show how to use android.support.v7.app.AlertDialog#setMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddTodoItem.java    From Minitask with Apache License 2.0 6 votes vote down vote up
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
    // if the date is in the past tell user to choose again
    if (dateTimeUtils.checkInvalidDate(year, monthOfYear, dayOfMonth)){
        AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
        alertDialog.setTitle("Date not valid!");
        alertDialog.setIcon(R.drawable.ic_warning_black_24dp);
        alertDialog.setMessage("You are selecting a time a point of time in the past!");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
        return;
    }

    // set date value to the value user selected and change the text
    date = dateTimeUtils.dateToString(year, monthOfYear, dayOfMonth);
    reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
 
Example 2
Source File: AddTodoItem.java    From Minitask with Apache License 2.0 6 votes vote down vote up
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
    // if date is not chosen first but time is chosen -> make today the default date.
    // also check for valid time, must be today but not the past hour or minutes.
    if (date.equals(dateTimeUtils.fillDateIfEmpty("")) && dateTimeUtils.checkInvalidTime(hourOfDay, minute)) {
        AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
        alertDialog.setTitle("Time not valid!");
        alertDialog.setMessage("You are selecting a point of time in the past!");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
        return;
    }

    // set time value and update text
    time = dateTimeUtils.timeToString(hourOfDay, minute);
    reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
 
Example 3
Source File: MainActivity.java    From LecteurOPUS with GNU General Public License v3.0 6 votes vote down vote up
private void enableReaderMode() {
    Log.i(TAG, "Enabling reader mode");
    Activity activity = this;
    NfcAdapter nfc = NfcAdapter.getDefaultAdapter(activity);
    if (!nfc.isEnabled()) {
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle(getString(R.string.disable_title));
        alertDialog.setMessage(getString(R.string.nfc_disable));
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));

                    }
                });
        alertDialog.show();
    }
    else if (nfc != null) {
        nfc.enableReaderMode(activity, mCardReader, FLAG_MIFARE | FLAG_OPUS, null);
    }
}
 
Example 4
Source File: ArticlesFragment.java    From WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void showAutoLoginFail() {
    final AlertDialog alertDialog = new AlertDialog.Builder(getContext()).create();
    alertDialog.setTitle(R.string.warning_title);
    alertDialog.setMessage(getString(R.string.tip));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.sure), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            MainActivity main = (MainActivity) getActivity();
            main.navigateToLogin();
            alertDialog.dismiss();
        }
    });
    alertDialog.show();
}
 
Example 5
Source File: WaypointNavigationActivity.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
private void showDropoffDialog() {
  AlertDialog alertDialog = new AlertDialog.Builder(this).create();
  alertDialog.setMessage(getString(R.string.dropoff_dialog_text));
  alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dropoff_dialog_positive_text),
    (dialogInterface, in) -> fetchRoute(getLastKnownLocation(), points.remove(0)));
  alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.dropoff_dialog_negative_text),
    (dialogInterface, in) -> {
      // Do nothing
    });

  alertDialog.show();
}
 
Example 6
Source File: CompassActivity.java    From Travel-Mate with MIT License 5 votes vote down vote up
/**
 * Check AccelerometerSensor in device
 **/
private void getAccelerometerSensor() {
    PackageManager mManager = getPackageManager();
    boolean hasAccelerometer = mManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);
    boolean hasMagneticSensor = mManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS);
    if (!hasAccelerometer || !hasMagneticSensor) {
        AlertDialog alertDialog = new AlertDialog.Builder(CompassActivity.this).create();
        alertDialog.setTitle(getResources().getString(R.string.compass_dialog_header));
        alertDialog.setMessage(getResources().getString(R.string.compass_dialog_description));
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.compass_dialog_confirm),
                (dialog, which) -> dialog.dismiss());
        alertDialog.show();
    }
}
 
Example 7
Source File: AboutFragment.java    From go-bees with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Shows a dialog with given data.
 *
 * @param title dialog title.
 * @param body  dialog text.
 */
private void showDialog(String title, String body) {
    AlertDialog alertDialog = new AlertDialog.Builder(getContext()).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(AndroidUtils.fromHtml(body));
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.close_btn),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 8
Source File: GameFragment.java    From block-this with GNU General Public License v3.0 5 votes vote down vote up
public void displayDialog(){
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setTitle("Thank you!");
    alertDialog.setMessage("By installing any of these games, you support this app's existence and further development." +
            " Without your help, all of this would not be possible. Thank you!");
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Okay, I understand",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    sharedPreferences.edit().putBoolean("seen_games_dialog", true).apply();
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 9
Source File: TimingActivity.java    From Lamp with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void sendTime() {
    if (switchOpen) {

        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle(getResources().getString(R.string.remind));
        dialog.setMessage(getResources().getString(R.string.wait));
        dialog.show();

        Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int min = c.get(Calendar.MINUTE);

        String hourStr = hour + "";
        String minStr = min + "";

        if (hour < 10) {
            hourStr = "0" + hour + "";
        }

        if (min < 10) {
            minStr = "0" + min + "";
        }

        ControlLight.sendTime(CommandUtils.TIMING_CURRENT, hourStr, minStr);
        startAPM.postDelayed(new Runnable() {
            @Override
            public void run() {
                ControlLight.sendTime(CommandUtils.TIMING_ON_1, time[0], time[1]);

                startAPM.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ControlLight.sendTime(CommandUtils.TIMING_ON_2, time[2], time[3]);
                        dialog.cancel();
                        finishThis();
                    }
                }, 1000);

            }
        }, 1000);


    } else {
        ControlLight.sendOrder(CommandUtils.TIMING_OFF);

        finishThis();
    }

}