List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:com.coincollection.ReorderCollections.java
private void showUnsavedChangesMessage() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Leaving this page will erase your unsaved changes, are you sure you want to exit?") .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { closeFragment();/* w w w . j a v a2s . c o m*/ } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.chaitu.lmscalendar.ui.UrlDialog.java
@Override @NonNull/*from ww w . j av a 2s .c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = (MainActivity) getActivity(); ViewGroup nullViewGroup = null; // Avoid bad lint warning in inflate() View view = mActivity.getLayoutInflater().inflate(R.layout.urldialog, nullViewGroup); mTextCalendarUrl = (EditText) view.findViewById(R.id.TextCalendarUrl); mTextUsername = (EditText) view.findViewById(R.id.TextUsername); mTextPassword = (EditText) view.findViewById(R.id.TextPassword); Settings settings = mActivity.getSettings(); mTextCalendarUrl.setText(settings.getString(Settings.PREF_LASTURL)); mTextUsername.setText(settings.getString(Settings.PREF_LASTURLUSERNAME)); mTextPassword.setText(settings.getString(Settings.PREF_LASTURLPASSWORD)); mTextCalendarUrl.selectAll(); //sync intervals mSpinnerSyncInterval = (Spinner) view.findViewById(R.id.sync_interval); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mActivity.getApplicationContext(), R.array.sync_intervals, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner mSpinnerSyncInterval.setAdapter(adapter); mSpinnerCalendar = (Spinner) view.findViewById(R.id.calendar); //calendar List<CalendarModel> calendars = EventUtil.readCalendars(mActivity.getApplicationContext(), mActivity.getApplicationContext().getContentResolver()); ArrayAdapter<CalendarModel> adapter1 = new ArrayAdapter<CalendarModel>(mActivity.getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, calendars); mSpinnerCalendar.setAdapter(adapter1); String name = settings.getString(Settings.PREF_LASTCALENDARNAME); int id = settings.getInt(Settings.PREF_LASTCALENDARID); if (id > 0 && name != null && !name.isEmpty()) { CalendarModel cal = new CalendarModel(id, name); mSpinnerCalendar.setSelection(adapter1.getPosition(cal)); } DialogInterface.OnClickListener okTask; okTask = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface iface, int id) { // We override this in onStart() } }; DialogInterface.OnClickListener cancelTask; cancelTask = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface iface, int id) { iface.cancel(); } }; AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); AlertDialog dlg = builder.setIcon(R.mipmap.ic_launcher).setTitle(R.string.enter_source_url).setView(view) .setPositiveButton(android.R.string.ok, okTask) .setNegativeButton(android.R.string.cancel, cancelTask).create(); dlg.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return dlg; }
From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java
@Override public void showDialogComplete() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.complete) .setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() { @Override/*from w w w.j av a 2s .c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mMessageHandler.postDelayed(new Runnable() { @Override public void run() { finish(); } }, 100); } }).setNegativeButton(R.string.view_console, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); try { builder.create().show(); } catch (Exception ignored) { } }
From source file:com.example.android.wearable.speedtracker.WearableMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate()"); setContentView(R.layout.main_activity); /*//from w ww . jav a2 s . c om * Enables Always-on, so our app doesn't shut down when the watch goes into ambient mode. * Best practice is to override onEnterAmbient(), onUpdateAmbient(), and onExitAmbient() to * optimize the display for ambient mode. However, for brevity, we aren't doing that here * to focus on learning location and permissions. For more information on best practices * in ambient mode, check this page: * https://developer.android.com/training/wearables/apps/always-on.html */ setAmbientEnabled(); mCalendar = Calendar.getInstance(); // Enables app to handle 23+ (M+) style permissions. mGpsPermissionApproved = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED; mGpsPermissionNeededMessage = getString(R.string.permission_rationale); mAcquiringGpsMessage = getString(R.string.acquiring_gps); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mSpeedLimit = sharedPreferences.getInt(PREFS_SPEED_LIMIT_KEY, SPEED_LIMIT_DEFAULT_MPH); mSpeed = 0; mWaitingForGpsSignal = true; /* * If this hardware doesn't support GPS, we warn the user. Note that when such device is * connected to a phone with GPS capabilities, the framework automatically routes the * location requests from the phone. However, if the phone becomes disconnected and the * wearable doesn't support GPS, no location is recorded until the phone is reconnected. */ if (!hasGps()) { Log.w(TAG, "This hardware doesn't have GPS, so we warn user."); new AlertDialog.Builder(this).setMessage(getString(R.string.gps_not_available)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { dialog.cancel(); } }).setCancelable(false).create().show(); } setupViews(); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API).addApi(Wearable.API) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); }
From source file:com.google.android.apps.iosched2.ui.SetupFragment.java
protected void validateSetting(final String trackerEvent, final Setup.EventId eventId, final int cityId) { AlertDialog.Builder eventConfirmation = new AlertDialog.Builder(getActivity()) .setTitle(R.string.setup_confirm_title).setIcon(android.R.drawable.ic_dialog_info) .setMessage(getString(R.string.setup_confirm_text, getText(cityId))); eventConfirmation//from w w w. j av a2 s. c o m .setPositiveButton(R.string.setup_accept, new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { fireTrackerEvent(trackerEvent); mListener.setupSelected(eventId); dialog.dismiss(); } }).setNegativeButton(R.string.setup_decline, new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); eventConfirmation.show(); }
From source file:ela.riskey.parammod.MainActivity.java
private void help() { hDialog = new AlertDialog.Builder(MainActivity.this); hDialog.setTitle(R.string.help).setNeutralButton(R.string.keluar, new DialogInterface.OnClickListener() { @Override/* ww w. j a v a 2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.cancel(); } }); LayoutInflater inflater = getLayoutInflater(); View troubleView = inflater.inflate(R.layout.help, null, false); hDialog.setView(troubleView); hDialog.create().show(); }
From source file:com.safecell.AccountFormActivity.java
public boolean accountNewProfileResponse() { String createAccountFromProfile = null; createAccountFromProfile = accountCreateByProfiles(); dialogDismiss = false;//from ww w. jav a 2s . c o m if (createAccountFromProfile != null) { CreateAccountFromProfileResponseHandler createAccountFromProfileResponseHandler = new CreateAccountFromProfileResponseHandler( AccountFormActivity.this, versionName); createAccountFromProfileResponseHandler.readAccountResponse(createAccountFromProfile); dialogDismiss = true; finish(); Intent mIntent = new Intent(AccountFormActivity.this, HomeScreenActivity.class); startActivity(mIntent); } else { dialogDismiss = true; new AlertDialog.Builder(context).setMessage(message) .setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); } return dialogDismiss; }
From source file:com.safecell.AccountFormActivity.java
public boolean accountResponse() { HttpResponse accountHttpResponse = accountCreateByAccount(); dialogDismiss = false;//from w ww . j a v a 2 s. co m if (accountHttpResponse != null) { SubmitAccountDetailsReponseHandler sumbitAccountDetailsReponseHandler = new SubmitAccountDetailsReponseHandler( AccountFormActivity.this, versionName); synchronized (profilesRepository) { sumbitAccountDetailsReponseHandler.readAccountResponse(accountHttpResponse); /*SendActivateSubscriptionEmail sendActivateSubscriptionEmail = new SendActivateSubscriptionEmail( AccountFormActivity.this); sendActivationEmail = sendActivateSubscriptionEmail .postRequest();*/ dialogDismiss = true; Intent mIntent = new Intent(AccountFormActivity.this, HomeScreenActivity.class); startActivity(mIntent); createAccountUniqueID(""); finish(); } } else { dialogDismiss = true; new AlertDialog.Builder(context).setMessage(message) .setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); } return dialogDismiss; }
From source file:de.thecamper.android.androidtools.UpdateChecker.java
/** * show a AlertDialog to inform the user of the update and let him download * the new version of the app// w ww. j av a 2 s.c om */ public void showUpdateAlert() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(R.string.updateTitle)); builder.setMessage(context.getString(R.string.updateAvailable)); builder.setCancelable(false); builder.setPositiveButton(context.getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(appURL)); context.startActivity(intent); ((Activity) context).finish(); } }); builder.setNegativeButton(context.getString(R.string.later), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.google.android.apps.authenticator.backup.BackupActivity.java
private void onRestoreButtonPressed() { Importer importer = new Importer(); JSONObject json = readJsonFromFile(); int accountsImported = importer.importFromJson(json, DependencyInjector.getAccountDb()); if (accountsImported == -1) { Toast.makeText(this, R.string.restore_failed, Toast.LENGTH_SHORT).show(); } else {//ww w.java2s .c o m String text = ""; if (accountsImported == 1) { text = getString(R.string.restore_success, accountsImported, "."); } else { text = getString(R.string.restore_success, accountsImported, "s."); } text = text + "\n\n" + getString(R.string.delete_restore_file, BACKUP_FILE_STRING); new AlertDialog.Builder(this).setTitle(getString(R.string.delete_restore_file, BACKUP_FILE)) .setMessage(text) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { deleteRestoreFile(); dialog.dismiss(); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); } }