List of usage examples for android.app AlertDialog.Builder AlertDialog.Builder
public Builder(Context context)
From source file:com.QuarkLabs.BTCeClient.MainActivity.java
private void onVersionUpdate(final SharedPreferences sharedPreferences) { final String keyToCheck = "needNotifyAboutNewSecuritySystem"; boolean needNotify = sharedPreferences.getBoolean(keyToCheck, true); if (needNotify) { //getting old values String key = sharedPreferences.getString("key", ""); String secret = sharedPreferences.getString("secret", ""); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); SharedPreferences.Editor editor = sharedPreferences.edit(); if (key.length() != 0) { editor.putString(SettingsFragment.KEY_API_KEY, SecurityManager.getInstance(this).encryptString(key)); }/*from ww w .j a va2 s . c o m*/ if (secret.length() != 0) { editor.putString(SettingsFragment.KEY_API_SECRET, SecurityManager.getInstance(this).encryptString(secret)); } editor.putString("key", ""); editor.putString("secret", ""); editor.commit(); String messageTitle = "New security system"; String message = "New security system is added with this update. " + "Now sensitive API credentials will be stored in encrypted state, " + "it will save them from the leak even if device is rooted."; new AlertDialog.Builder(this).setNeutralButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(keyToCheck, false); editor.commit(); } }).setTitle(messageTitle).setMessage(message).show(); } }
From source file:org.gdgsp.fragment.WebViewFragment.java
public void getCode(String url) { Ion.with(this).load(Other.getLoginUrl(activity)).setBodyParameter("code", Other.getQuery(url, "code")) .asJsonObject().setCallback(new FutureCallback<JsonObject>() { @Override// w w w . j av a 2s . c o m public void onCompleted(Exception e, JsonObject json) { progressDialog.dismiss(); gettingCode = false; if (e != null) { loginError(); return; } if (!json.get("is_error").getAsBoolean()) { String refresh_token = json.get("refresh_token").getAsString(); String qr_code = json.get("qr_code").getAsString(); if (!refresh_token.equals("")) { SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(activity); SharedPreferences.Editor editor = preferences.edit(); editor.putString("refresh_token", refresh_token); editor.putString("qr_code", qr_code); editor.commit(); Intent intent = new Intent(activity, MainActivity.class); intent.putExtra("fromlogin", true); if (activity.getIntent().hasExtra("eventid")) { MainActivity.openEvent = activity.getIntent().getIntExtra("eventid", 0); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } } else { String description = json.get("description").getAsString(); if (description.equals("error")) { loginError(); } else if (description.equals("none")) { AlertDialog alertDialog = new AlertDialog.Builder(activity) .setMessage(getString(R.string.login_nonmember).replace("{appname}", getString(R.string.app_name))) .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { getArguments().remove("islogin"); webView.loadUrl("http://meetup.com/" + getString(R.string.meetup_id)); } }) .setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { activity.finish(); } }) .create(); alertDialog.show(); } else if (description.equals("pending")) { AlertDialog alertDialog = new AlertDialog.Builder(activity) .setMessage(getString(R.string.login_pending).replace("{appname}", getString(R.string.app_name))) .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { activity.finish(); } }) .create(); alertDialog.show(); } } } }); }
From source file:org.steveleach.scoresheet.ui.ScoresheetActivity.java
private void showAbout() { // Inflate the about message contents View messageView = getLayoutInflater().inflate(R.layout.about, null, false); TextView version = (TextView) messageView.findViewById(R.id.txtAppVersion); String versionText = getApplicationContext().getString(R.string.appVersionText, context.applicationVersion()); version.setText(versionText);//ww w. java 2s.com AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.mipmap.ic_launcher); builder.setTitle(R.string.app_name); builder.setView(messageView); builder.create(); builder.show(); }
From source file:com.arquitetaweb.observatorio.MainActivity.java
@Override public void onBackPressed() { if (isTaskRoot()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.pgtaSair).setCancelable(false) .setPositiveButton("Sim", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainActivity.super.onBackPressed(); }/*from ww w . ja va 2 s. c o m*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { super.onBackPressed(); } }
From source file:com.quaninventory.scanner.activities.DrawerActivity.java
public void exitApp() { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Exit") .setMessage("Quit the application?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override// www . j a v a 2 s .c o m public void onClick(DialogInterface dialog, int which) { finish(); } }).setNegativeButton("No", null).show(); }
From source file:com.vuze.android.remote.AndroidUtils.java
public static void showConnectionError(final Activity activity, final String errMsg, final boolean allowContinue) { if (AndroidUtils.DEBUG) { Log.d(TAG, "showConnectionError.string " + AndroidUtils.getCompressedStackTrace()); }/*from w w w .ja v a2 s . c o m*/ if (activity == null) { Log.e(null, "No activity for error message " + errMsg); return; } activity.runOnUiThread(new Runnable() { public void run() { if (activity.isFinishing()) { if (DEBUG) { System.out.println("can't display -- finishing"); } return; } Builder builder = new AlertDialog.Builder(activity).setTitle(R.string.error_connecting) .setMessage(errMsg).setCancelable(true) .setNegativeButton(R.string.action_logout, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (activity.isTaskRoot()) { RemoteUtils.openRemoteList(activity); } activity.finish(); } }); if (allowContinue) { builder.setPositiveButton(R.string.button_continue, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); } AndroidUtils.openSingleAlertDialog(activity, builder); } }); }
From source file:org.guohai.android.cta.CoordinateTalk.java
/** * ??//from w w w. j a va2 s. c o m */ @Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case MENU_CONFIG: Intent intent = new Intent(); intent.setClass(CoordinateTalk.this, Config.class); startActivity(intent); break; case MENU_HELP: new AlertDialog.Builder(CoordinateTalk.this).setTitle("About Coordinate Talk") .setMessage("your device imei\n" + Tools.GetPhoneImei(getApplicationContext())).show(); break; case MENU_EXIT: this.finish(); break; } return true; }
From source file:io.coldstart.android.TrapListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.GCMStatus: { subscribeToMessages();// www . j a v a2s . c om return true; } case R.id.ChangeKey: { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putBoolean("firstRun", true); editor.putString("APIKey", ""); editor.putString("keyPassword", ""); editor.commit(); Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); finish(); overridePendingTransition(0, 0); startActivity(intent); return true; } case R.id.PauseAlerts: { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Delete Traps for selected host?") .setMessage( "Are you sure you want to logout?\nYou'll no longer receive any alerts, they won't be cached on the server and the app will close.") .setPositiveButton("Yes, Logout", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.i("onOptionsItemSelected", "Logging Out"); (new Thread() { public void run() { API api = new API(); try { if (api.logoutGCMAccount(settings.getString("APIKey", ""), settings.getString("keyPassword", ""), securityID)) { //We successfully logged out runOnUiThread(new Runnable() { public void run() { gcmStatus.setIcon(R.drawable.ic_action_gcm_failed); Toast.makeText(getApplicationContext(), "Succesfully logged out. Tap the GCM icon or relaunch app to login again", Toast.LENGTH_SHORT).show(); } }); } else { //TODO Popup to the user that there was a problem logging out runOnUiThread(new Runnable() { public void run() { gcmStatus.setIcon(R.drawable.ic_action_gcm_failed); Toast.makeText(getApplicationContext(), "There was a problem logging out.", Toast.LENGTH_SHORT) .show(); } }); } runOnUiThread(new Runnable() { public void run() { TrapListActivity.this.invalidateOptionsMenu(); } }); } catch (Exception e) { //TODO this is probably pretty bad! e.printStackTrace(); } } }).start(); } }).setNegativeButton("No", null).show(); return true; } case R.id.Settings: { Intent SettingsIntent = new Intent(TrapListActivity.this, SettingsFragment.class); this.startActivityForResult(SettingsIntent, DISPLAY_SETTINGS); return true; } case R.id.SeeAPIKey: { if (dialogFragment != null) dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); Log.i("prev", "Removing"); } ft.addToBackStack(null); // Create and show the dialog. dialogFragment = ViewAPIKeyDialog.newInstance(settings.getString("APIKey", "")); dialogFragment.setCancelable(true); dialogFragment.show(ft, "dialog"); return true; } /*case R.id.Filters: { if(dialogFragment != null) dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); Log.i("prev","Removing"); } ft.addToBackStack(null); // Create and show the dialog. dialogFragment = HostFilterDialog.newInstance(); dialogFragment.setCancelable(true); dialogFragment.show(ft, "dialog"); return true; }*/ } return false; }
From source file:org.gdgsp.fragment.WebViewFragment.java
private void loginError() { AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle(getString(R.string.login_error)) .setMessage(getString(R.string.login_error_sub)) .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override/*from w ww. j av a 2s . com*/ public void onClick(DialogInterface p1, int p2) { webView.loadUrl(Other.getLoginUrl(activity)); } }).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { activity.finish(); } }).create(); alertDialog.show(); }
From source file:com.vuze.android.remote.AndroidUtils.java
public static void showDialog(final Activity activity, final CharSequence title, final CharSequence msg) { activity.runOnUiThread(new Runnable() { public void run() { if (activity.isFinishing()) { if (DEBUG) { System.out.println("can't display -- finishing"); }// w w w.j a va 2s .co m return; } Builder builder = new AlertDialog.Builder(activity).setMessage(msg).setCancelable(true) .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); if (title != null) { builder.setTitle(title); } builder.show(); } }); }