Example usage for android.support.v4.app AlertDialog.Builder setMessage

List of usage examples for android.support.v4.app AlertDialog.Builder setMessage

Introduction

In this page you can find the example usage for android.support.v4.app AlertDialog.Builder setMessage.

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:in.codehex.facilis.MainActivity.java

/**
 * Display an alert when logout icon is clicked.
 *//*from w  w w .  j  a v  a  2  s.  c  o  m*/
private void showAlertLogout() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("Logout");
    alertDialog.setMessage("Are you sure you want to logout?");
    alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // TODO: send logout request to API
            userPreferences.edit().clear().commit();
            mIntent = new Intent(MainActivity.this, LoginActivity.class);
            mIntent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(mIntent);
        }
    });
    alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    alertDialog.show();
}

From source file:com.example.leandromaguna.myapp.Presentation.PlacesMap.PlacesMapActivity.java

private void buildAlertMessageNoGps() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Your GPS seems to be disabled, do you want to enable it?").setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(@SuppressWarnings("unused") final DialogInterface dialog,
                        @SuppressWarnings("unused") final int id) {
                    startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                    mMap.setMyLocationEnabled(true);
                }/*from   w ww .j  av  a 2  s.co  m*/
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
                    dialog.cancel();
                }
            });
    final AlertDialog alert = builder.create();
    alert.show();
}

From source file:httbdd.cse.nghiatran.halofind.fragment.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.demo, container, false);
    mSlidingUpPanelLayout = (SlidingUpPanelLayout) rootView.findViewById(R.id.slidingLayout);
    mSlidingUpPanelLayout.setEnableDragViewTouchEvents(true);

    int mapHeight = getResources().getDimensionPixelSize(R.dimen.map_height);
    mSlidingUpPanelLayout.setPanelHeight(mapHeight); // you can use different height here

    mSlidingUpPanelLayout.setPanelSlideListener((SlidingUpPanelLayout.PanelSlideListener) getActivity());
    mapView = (MapView) rootView.findViewById(R.id.mapView);
    //        lat = getIntent().getDoubleExtra("lat", lat);
    //        longt = getIntent().getDoubleExtra("long", longt);
    //        addresss = getIntent().getStringExtra("address");
    //        title = getIntent().getStringExtra("title");
    mapView.onCreate(savedInstanceState);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);// w w  w . j a  v a 2 s. com
    locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    updateValuesFromBundle(savedInstanceState);
    if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
        alert.setMessage("GPS is disabled in your device. Would you like to enable it?");
        alert.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alert.setNegativeButton("Go to Settings", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                Intent I = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(I);
            }
        });
        AlertDialog al_gps = alert.create();
        al_gps.show();
    } else {
        if (ActivityCompat.checkSelfPermission(getActivity(),
                Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(getActivity(),
                        Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                    (android.location.LocationListener) this);
        }
    }
    mapView.getMapAsync(this);
    createLocationRequest();
    return rootView;
}

From source file:de.geeksfactory.opacclient.frontend.AccountEditActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        supportFinishAfterTransition();//from   ww w.j a v a 2 s . c o  m
        return true;
    } else if (item.getItemId() == R.id.action_accept) {
        saveAndCheck();
        return true;
    } else if (item.getItemId() == R.id.action_cancel) {
        if (getIntent().hasExtra("adding") && getIntent().getBooleanExtra("adding", false)) {
            delete();
        }
        supportFinishAfterTransition();
        return true;
    } else if (item.getItemId() == R.id.action_delete) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.account_delete_confirm).setCancelable(true)
                .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface d, int id) {
                        d.cancel();
                    }
                }).setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface d, int id) {
                        d.dismiss();
                        delete();
                        finish();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface d) {
                        if (d != null) {
                            d.cancel();
                        }
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.sonnychen.aviationhk.MainActivity.java

public void showBookings() {
    if (!TextUtils.isEmpty(BaseApplication.HKACPassword)) {
        launchBookingViewer();/*from w  ww  .ja v  a 2s  . c o  m*/
        return;
    }

    View promptsView = LayoutInflater.from(this).inflate(R.layout.simple_password_prompt, null);
    final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput);

    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setView(promptsView);
    // set dialog message
    alertDialogBuilder.setCancelable(true)
            .setPositiveButton(R.string.go, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    /** DO THE METHOD HERE WHEN PROCEED IS CLICKED*/
                    String password = (userInput.getText()).toString();

                    /** CHECK FOR USER'S INPUT **/
                    if (!TextUtils.isEmpty(password)) {
                        BaseApplication.HKACPassword = password;
                        SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
                        SharedPreferences.Editor editor = settings.edit();
                        editor.putString("HKACPassword", BaseApplication.HKACPassword);
                        editor.apply();

                        launchBookingViewer();
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                        builder.setTitle(R.string.error);
                        builder.setMessage(R.string.pdf_password_is_required);
                        builder.create().show();
                    }
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }

            }

    );

    alertDialogBuilder.create().show();
}

From source file:org.asteroidos.sync.fragments.DeviceDetailFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    mFab = (FloatingActionButton) view.findViewById(R.id.fab);
    mFab.setOnClickListener(new View.OnClickListener() {
        @Override/* w  w w.j a va 2  s .  c  o  m*/
        public void onClick(View view) {
            if (mConnected)
                mConnectListener.onDisconnectRequested();
            else
                mConnectListener.onConnectRequested();
        }
    });

    mConnectedText = (TextView) view.findViewById(R.id.info_connected);
    mConnectedImage = (ImageView) view.findViewById(R.id.info_icon_connected);

    mBatteryText = (TextView) view.findViewById(R.id.info_battery);
    mBatteryImage = (ImageView) view.findViewById(R.id.info_icon_battery);

    CardView weatherCard = (CardView) view.findViewById(R.id.card_view1);
    weatherCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
            alert.setTitle(R.string.weather_settings);
            alert.setMessage(R.string.enter_city_name);

            final SharedPreferences settings = getActivity().getSharedPreferences(WeatherService.PREFS_NAME, 0);
            final EditText edittext = new EditText(getActivity());
            int padding = (int) DeviceDetailFragment.this.getResources().getDisplayMetrics().density * 15;
            edittext.setPadding(padding, padding, padding, padding);
            edittext.setText(
                    settings.getString(WeatherService.PREFS_CITY_NAME, WeatherService.PREFS_CITY_NAME_DEFAULT));
            alert.setView(edittext);

            alert.setPositiveButton(getString(R.string.generic_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String cityName = edittext.getText().toString();
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString(WeatherService.PREFS_CITY_NAME, cityName);
                    editor.apply();
                }
            });

            alert.show();
        }
    });

    CardView findCard = (CardView) view.findViewById(R.id.card_view2);
    findCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent("org.asteroidos.sync.NOTIFICATION_LISTENER");
            i.putExtra("event", "posted");
            i.putExtra("packageName", "org.asteroidos.sync");
            i.putExtra("id", 0xa57e401d);
            i.putExtra("appName", getString(R.string.app_name));
            i.putExtra("appIcon", "");
            i.putExtra("summary", getString(R.string.watch_finder));
            i.putExtra("body", getString(R.string.phone_is_searching));
            getActivity().sendBroadcast(i);
        }
    });

    CardView screenshotCard = (CardView) view.findViewById(R.id.card_view3);
    screenshotCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getActivity().sendBroadcast(new Intent("org.asteroidos.sync.SCREENSHOT_REQUEST_LISTENER"));
        }
    });

    CardView notifSettCard = (CardView) view.findViewById(R.id.card_view4);
    notifSettCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(getActivity(), R.string.not_supported, Toast.LENGTH_SHORT).show();
        }
    });

    CardView timeSyncCard = (CardView) view.findViewById(R.id.card_view5);
    timeSyncCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getActivity().sendBroadcast(new Intent("org.asteroidos.sync.TIME_SYNC_LISTENER"));
        }
    });

    TextView unpairTextView = (TextView) view.findViewById(R.id.unpairTextView);
    unpairTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mDeviceListener.onDefaultDeviceUnselected();
        }
    });
}

From source file:com.appteam.nimbus.activity.homeActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override//  www. ja  v  a2 s  .  c  o m
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.navigation_to_profile) {
        // Handle the camera action
        Intent i = new Intent(homeActivity.this, Profile.class);
        startActivity(i);

    } else if (id == R.id.aboutus_nav) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(String.format("%1$s", getString(R.string.app_name)));
        builder.setMessage(getResources().getText(R.string.aboutus_text));
        builder.setPositiveButton("OK", null);
        builder.setIcon(R.mipmap.nimbus16);
        AlertDialog welcomeAlert = builder.create();
        welcomeAlert.show();
        ((TextView) welcomeAlert.findViewById(android.R.id.message))
                .setMovementMethod(LinkMovementMethod.getInstance());
    } else if (id == R.id.feedback_nav) {
        Intent intent = new Intent(Intent.ACTION_SENDTO);
        String uriText = "mailto:" + Uri.encode("appteam.nith@gmail.com") + "?subject="
                + Uri.encode("Reporting A Bug/Feedback") + "&body=" + Uri.encode(
                        "Hello, Appteam \nI want to report a bug/give feedback corresponding to the app Nimbus 2k16.\n.....\n\n-Your name");

        Uri uri = Uri.parse(uriText);
        intent.setData(uri);
        startActivity(Intent.createChooser(intent, "Send Email"));
    } else if (id == R.id.opensourcelicenses_nav) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(String.format("%1$s", getString(R.string.open_source_licenses)));
        builder.setMessage(getResources().getText(R.string.licenses_text));
        builder.setPositiveButton("OK", null);
        //builder.setIcon(R.mipmap.nimbus_icon);
        AlertDialog welcomeAlert = builder.create();
        welcomeAlert.show();
        ((TextView) welcomeAlert.findViewById(android.R.id.message))
                .setMovementMethod(LinkMovementMethod.getInstance());
    } else if (id == R.id.contributors_nav) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(String.format("%1$s", getString(R.string.contributors)));
        builder.setMessage(getResources().getText(R.string.contributors_text));
        builder.setPositiveButton("OK", null);
        //builder.setIcon(R.mipmap.nimbus_icon);
        AlertDialog welcomeAlert = builder.create();
        welcomeAlert.show();
        ((TextView) welcomeAlert.findViewById(android.R.id.message))
                .setMovementMethod(LinkMovementMethod.getInstance());
    } else if (id == R.id.notifications) {
        startActivity(new Intent(homeActivity.this, ViewActivity.class));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:ren.qinc.markdowneditors.view.EditorFragment.java

private void onNoSave() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.DialogTheme);
    builder.setMessage("????");
    builder.setNegativeButton("??", (dialog, which) -> {
        getActivity().finish();/*ww w  .ja  v a  2  s . c  o m*/

    }).setNeutralButton("?", (dialog, which) -> {
        dialog.dismiss();

    }).setPositiveButton("?", (dialog, which) -> {
        mPresenter.saveForExit(mName.getText().toString().trim(), mContent.getText().toString().trim(), true);

    }).show();
}

From source file:de.mkrtchyan.recoverytools.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View root = inflater.inflate(R.layout.fragment_settings, container, false);
    final SwitchCompat swShowAds = (SwitchCompat) root.findViewById(R.id.cbShowAds);
    final SwitchCompat swLog = (SwitchCompat) root.findViewById(R.id.cbLog);
    final SwitchCompat swDarkUI = (SwitchCompat) root.findViewById(R.id.cbDarkUI);
    final SwitchCompat swCheckUpdates = (SwitchCompat) root.findViewById(R.id.cbCheckUpdates);
    final AppCompatButton bShowLogs = (AppCompatButton) root.findViewById(R.id.bShowLogs);
    final AppCompatButton bReport = (AppCompatButton) root.findViewById(R.id.bReport);
    final AppCompatButton bShowChangelog = (AppCompatButton) root.findViewById(R.id.bShowChangelog);
    final AppCompatButton bReset = (AppCompatButton) root.findViewById(R.id.bReset);
    final AppCompatButton bClearCache = (AppCompatButton) root.findViewById(R.id.bClearCache);

    swDarkUI.setChecked(//from w  ww  . j  av a2s. c o  m
            Common.getBooleanPref(root.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_DARK_UI));
    swShowAds.setChecked(Common.getBooleanPref(root.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_ADS));
    swLog.setChecked(Common.getBooleanPref(root.getContext(), Shell.PREF_NAME, Shell.PREF_LOG));
    swCheckUpdates.setChecked(
            Common.getBooleanPref(root.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_CHECK_UPDATES));
    swShowAds.setChecked(Common.getBooleanPref(root.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_ADS));

    swDarkUI.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_DARK_UI,
                    isChecked);
            RashrActivity.isDark = isChecked;
        }
    });
    swLog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Shell.PREF_NAME, Shell.PREF_LOG, isChecked);
            root.findViewById(R.id.bShowLogs).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
        }
    });
    swCheckUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_CHECK_UPDATES,
                    isChecked);
            swCheckUpdates.setChecked(isChecked);
        }
    });
    swShowAds.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Constants.PREF_NAME, Constants.PREF_KEY_ADS, isChecked);
            swShowAds.setChecked(isChecked);
        }
    });

    final RashrActivity activity = (RashrActivity) getActivity();

    bReport.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ReportDialog dialog = new ReportDialog(activity, "");
            dialog.show();
        }
    });

    bShowLogs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Common.showLogs(view.getContext());
        }
    });

    bShowLogs.setVisibility(swLog.isChecked() ? View.VISIBLE : View.INVISIBLE);

    bReset.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AppCompatActivity activity = (AppCompatActivity) getActivity();
            SharedPreferences.Editor editor = activity
                    .getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().commit();
            editor = activity.getSharedPreferences(FlashUtil.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().commit();
            editor = activity.getSharedPreferences(Shell.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().commit();
        }
    });

    bClearCache.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(v.getContext());
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.delete_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (!Common.deleteFolder(Constants.PathToCWM, false)
                            || !Common.deleteFolder(Constants.PathToTWRP, false)
                            || !Common.deleteFolder(Constants.PathToPhilz, false)
                            || !Common.deleteFolder(Constants.PathToStockRecovery, false)
                            || !Common.deleteFolder(Constants.PathToStockKernel, false)) {
                        Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getActivity(), R.string.files_deleted, Toast.LENGTH_SHORT).show();
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });
            ConfirmationDialog.show();
        }
    });
    bShowChangelog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SettingsFragment.showChangelog(v.getContext());
        }
    });
    return root;
}

From source file:com.awt.supark.EditCar.java

public void showErrorDialog(String title, String content) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getContext(), R.style.AlertDialogStyle);
    alertBuilder.setTitle(title);//from  www .j a  v a2s  . c  o m
    alertBuilder.setMessage(content);
    alertBuilder.setPositiveButton("Ok", null);
    alertBuilder.show();
}