List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:com.safecell.LoginActivity.java
void dialogforWebview() { AlertDialog.Builder builder;//from w ww . j a v a 2 s. c o m Context mContext = LoginActivity.this; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.private_policy_layout, (ViewGroup) findViewById(R.id.layout_root)); final Activity activity = LoginActivity.this; wv = (WebView) layout.findViewById(R.id.webview); wv.getSettings().setJavaScriptEnabled(true); wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); wv.setWebViewClient(new HelloWebViewClient()); wv.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int newProgress) { activity.setProgress(newProgress * 100); if (newProgress == 100) { } }; }); wv.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // Log.v("errorCode", "errorcode "+errorCode + description); alertDialogForTermsConditions.cancel(); } }); // wv.loadUrl(URLs.REMOTE_URL + // "api/1/site_setting/terms_of_service.html"); wv.loadUrl("file:///android_asset/terms_of_service.html"); builder = new AlertDialog.Builder(mContext); builder.setView(layout); builder.setTitle("Policy"); builder.setPositiveButton("Accept", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { isTermsAcepted = true; dialog.cancel(); } }).setNegativeButton("Don't Accept", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { isTermsAcepted = false; dialog.cancel(); quitDialog("License", "Terms and conditions should accept. "); } }); alertDialogForTermsConditions = builder.create(); if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } try { alertDialogForTermsConditions.show(); } catch (Exception e) { e.printStackTrace(); } }
From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java
private void showNewNetworkProxyDialog(final ProxyAdapter proxyAdapter) { final int originalSelection = networkProxy.isSet() ? ProxyAdapter.PROXY : ProxyAdapter.NONE; View view = LayoutInflater.from(app).inflate(R.layout.debug_drawer_network_proxy, null); final EditText host = findById(view, R.id.debug_drawer_network_proxy_host); new AlertDialog.Builder(activity) // .setTitle("Set Network Proxy").setView(view) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override/*from www.java 2s .c o m*/ public void onClick(DialogInterface dialog, int i) { networkProxyView.setSelection(originalSelection); dialog.cancel(); } }).setPositiveButton("Use", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { String theHost = host.getText().toString(); if (!Strings.isBlank(theHost)) { String[] parts = theHost.split(":", 2); SocketAddress address = InetSocketAddress.createUnresolved(parts[0], Integer.parseInt(parts[1])); networkProxy.set(theHost); // Persist across restarts. proxyAdapter.notifyDataSetChanged(); // Tell the spinner to update. networkProxyView.setSelection(ProxyAdapter.PROXY); // And show the proxy. client.setProxy(new Proxy(HTTP, address)); } else { networkProxyView.setSelection(originalSelection); } } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { networkProxyView.setSelection(originalSelection); } }).show(); }
From source file:com.codeskraps.sbrowser.home.SBrowserActivity.java
private void doSearch() { final AlertDialog.Builder alertSearch = new AlertDialog.Builder(this); alertSearch.setTitle(getResources().getString(R.string.alertSearchTitle)); alertSearch.setMessage(getResources().getString(R.string.alertSearchSummary)); final EditText inputSearch = new EditText(this); inputSearch.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_URI); alertSearch.setView(inputSearch);//w w w. ja v a2 s . c o m alertSearch.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = inputSearch.getText().toString().trim(); webView.loadUrl("https://encrypted.google.com/search?q=" + value); } }); alertSearch.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alertSearch.show(); }
From source file:com.piusvelte.taplock.client.core.TapLockToggle.java
@Override protected void onResume() { super.onResume(); mProgressDialog = new ProgressDialog(this); mProgressDialog.setTitle(R.string.title_toggle); mProgressDialog.setMessage(mProgressMessage); mProgressDialog.setCancelable(true); mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override//from w w w . j a v a 2 s . c o m public void onCancel(DialogInterface dialog) { finish(); } }); mProgressDialog.setButton(getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mServiceInterface != null) { try { mServiceInterface.cancelRequest(); } catch (RemoteException e) { Log.e(TAG, e.toString()); } } dialog.cancel(); } }); mProgressDialog.show(); mDevices.clear(); final SharedPreferences sp = getSharedPreferences(KEY_PREFS, MODE_PRIVATE); Set<String> devices = sp.getStringSet(KEY_DEVICES, null); if (devices != null) { for (String device : devices) { try { mDevices.add(new JSONObject(device)); } catch (JSONException e) { Log.e(TAG, e.toString()); } } } // start the service before binding so that the service stays around for faster future connections startService(TapLock.getPackageIntent(this, TapLockService.class)); bindService(TapLock.getPackageIntent(this, TapLockService.class), this, BIND_AUTO_CREATE); }
From source file:com.breadwallet.presenter.activities.MainActivity.java
private void checkDeviceRooted() { final boolean hasBitcoin = CurrencyManager.getInstance(this).getBALANCE() > 0; boolean isDebuggable = 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE); if (RootHelper.isDeviceRooted() && !isDebuggable) { new Handler().postDelayed(new Runnable() { @Override/*from www . ja v a2s. com*/ public void run() { if (app == null) { Log.e(TAG, "WARNING: checkDeviceRooted: app - null"); return; } AlertDialog.Builder builder = new AlertDialog.Builder(app); builder.setTitle(R.string.device_security_compromised) .setMessage(String.format(getString(R.string.rooted_message), hasBitcoin ? getString(R.string.rooted_message_holder1) : "")) .setCancelable(false) .setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); if (app != null && !app.isDestroyed()) alert.show(); } }, 10000); } }
From source file:com.example.devesh.Coride.DriverRegistration.java
public void showSettingsAlert(String provider) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(DriverRegistration.this); alertDialog.setTitle(provider + " SETTINGS"); alertDialog.setMessage(provider + " is not enabled! Want to go to settings menu?"); alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); DriverRegistration.this.startActivity(intent); dialog.cancel(); }/* ww w. j a va 2 s .co m*/ }); alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(), "Enable location to use APP", Toast.LENGTH_SHORT).show(); dialog.cancel(); } }); alertDialog.show(); }
From source file:com.business.rushour.businessapp.RiderMainActivity.java
public void postride() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); // Setting Dialog Title alertDialog.setTitle("Post Ride"); // Setting Dialog Message alertDialog.setMessage(/*from w w w. j a v a2 s. c o m*/ "To Post Ride, you should be authenticated with your Driving License and Vehicle RC Information."); // Setting Icon to Dialog //alertDialog.setIcon(R.drawable.delete); // Setting Positive "Yes" Button alertDialog.setPositiveButton("Authenticate", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent aboutus = new Intent(getApplicationContext(), RiderRegistrationAsOwnerActivity.class); startActivity(aboutus); } }); // Setting Negative "NO" Button alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }
From source file:com.elekso.potfix.MainActivity.java
private void showGPSDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("Internet & GPS is required by Potfix. Would you like to enable it?") .setCancelable(false).setPositiveButton("Enable GPS", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(callGPSSettingIntent); }/* ww w .j a v a 2 s . c om*/ }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
From source file:com.piusvelte.sonet.core.SelectFriends.java
protected void loadFriends() { mFriends.clear();/* w w w . jav a2 s . c o m*/ // SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND, Entities.ESID}, new int[]{R.id.profile, R.id.name, R.id.selected}); SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected }); setListAdapter(sa); final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Long, String, Boolean> asyncTask = new AsyncTask<Long, String, Boolean>() { @Override protected Boolean doInBackground(Long... params) { boolean loadList = false; SonetCrypto sonetCrypto = SonetCrypto.getInstance(getApplicationContext()); // load the session Cursor account = getContentResolver().query(Accounts.getContentUri(SelectFriends.this), new String[] { Accounts.TOKEN, Accounts.SECRET, Accounts.SERVICE }, Accounts._ID + "=?", new String[] { Long.toString(params[0]) }, null); if (account.moveToFirst()) { mToken = sonetCrypto.Decrypt(account.getString(0)); mSecret = sonetCrypto.Decrypt(account.getString(1)); mService = account.getInt(2); } account.close(); String response; switch (mService) { case TWITTER: break; case FACEBOOK: if ((response = SonetHttpClient.httpResponse(mHttpClient, new HttpGet( String.format(FACEBOOK_FRIENDS, FACEBOOK_BASE_URL, Saccess_token, mToken)))) != null) { try { JSONArray friends = new JSONObject(response).getJSONArray(Sdata); for (int i = 0, l = friends.length(); i < l; i++) { JSONObject f = friends.getJSONObject(i); HashMap<String, String> newFriend = new HashMap<String, String>(); newFriend.put(Entities.ESID, f.getString(Sid)); newFriend.put(Entities.PROFILE, String.format(FACEBOOK_PICTURE, f.getString(Sid))); newFriend.put(Entities.FRIEND, f.getString(Sname)); // need to alphabetize if (mFriends.isEmpty()) mFriends.add(newFriend); else { String fullName = f.getString(Sname); int spaceIdx = fullName.lastIndexOf(" "); String newFirstName = null; String newLastName = null; if (spaceIdx == -1) newFirstName = fullName; else { newFirstName = fullName.substring(0, spaceIdx++); newLastName = fullName.substring(spaceIdx); } List<HashMap<String, String>> newFriends = new ArrayList<HashMap<String, String>>(); for (int i2 = 0, l2 = mFriends.size(); i2 < l2; i2++) { HashMap<String, String> oldFriend = mFriends.get(i2); if (newFriend == null) { newFriends.add(oldFriend); } else { fullName = oldFriend.get(Entities.FRIEND); spaceIdx = fullName.lastIndexOf(" "); String oldFirstName = null; String oldLastName = null; if (spaceIdx == -1) oldFirstName = fullName; else { oldFirstName = fullName.substring(0, spaceIdx++); oldLastName = fullName.substring(spaceIdx); } if (newFirstName == null) { newFriends.add(newFriend); newFriend = null; } else { int comparison = oldFirstName.compareToIgnoreCase(newFirstName); if (comparison == 0) { // compare firstnames if (newLastName == null) { newFriends.add(newFriend); newFriend = null; } else if (oldLastName != null) { comparison = oldLastName.compareToIgnoreCase(newLastName); if (comparison == 0) { newFriends.add(newFriend); newFriend = null; } else if (comparison > 0) { newFriends.add(newFriend); newFriend = null; } } } else if (comparison > 0) { newFriends.add(newFriend); newFriend = null; } } newFriends.add(oldFriend); } } if (newFriend != null) newFriends.add(newFriend); mFriends = newFriends; } } loadList = true; } catch (JSONException e) { Log.e(TAG, e.toString()); } } break; case MYSPACE: break; case LINKEDIN: break; case FOURSQUARE: break; case IDENTICA: break; case GOOGLEPLUS: break; case CHATTER: break; } return loadList; } @Override protected void onPostExecute(Boolean loadList) { if (loadList) { // SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND}, new int[]{R.id.profile, R.id.name}); SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected }); sa.setViewBinder(mViewBinder); setListAdapter(sa); } if (loadingDialog.isShowing()) loadingDialog.dismiss(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(mAccountId); }
From source file:com.shafiq.myfeedle.core.SelectFriends.java
protected void loadFriends() { mFriends.clear();// ww w . ja v a 2 s . c o m // SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND, Entities.ESID}, new int[]{R.id.profile, R.id.name, R.id.selected}); SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected }); setListAdapter(sa); final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Long, String, Boolean> asyncTask = new AsyncTask<Long, String, Boolean>() { @Override protected Boolean doInBackground(Long... params) { boolean loadList = false; MyfeedleCrypto myfeedleCrypto = MyfeedleCrypto.getInstance(getApplicationContext()); // load the session Cursor account = getContentResolver().query(Accounts.getContentUri(SelectFriends.this), new String[] { Accounts.TOKEN, Accounts.SECRET, Accounts.SERVICE }, Accounts._ID + "=?", new String[] { Long.toString(params[0]) }, null); if (account.moveToFirst()) { mToken = myfeedleCrypto.Decrypt(account.getString(0)); mSecret = myfeedleCrypto.Decrypt(account.getString(1)); mService = account.getInt(2); } account.close(); String response; switch (mService) { case TWITTER: break; case FACEBOOK: if ((response = MyfeedleHttpClient.httpResponse(mHttpClient, new HttpGet( String.format(FACEBOOK_FRIENDS, FACEBOOK_BASE_URL, Saccess_token, mToken)))) != null) { try { JSONArray friends = new JSONObject(response).getJSONArray(Sdata); for (int i = 0, l = friends.length(); i < l; i++) { JSONObject f = friends.getJSONObject(i); HashMap<String, String> newFriend = new HashMap<String, String>(); newFriend.put(Entities.ESID, f.getString(Sid)); newFriend.put(Entities.PROFILE, String.format(FACEBOOK_PICTURE, f.getString(Sid))); newFriend.put(Entities.FRIEND, f.getString(Sname)); // need to alphabetize if (mFriends.isEmpty()) mFriends.add(newFriend); else { String fullName = f.getString(Sname); int spaceIdx = fullName.lastIndexOf(" "); String newFirstName = null; String newLastName = null; if (spaceIdx == -1) newFirstName = fullName; else { newFirstName = fullName.substring(0, spaceIdx++); newLastName = fullName.substring(spaceIdx); } List<HashMap<String, String>> newFriends = new ArrayList<HashMap<String, String>>(); for (int i2 = 0, l2 = mFriends.size(); i2 < l2; i2++) { HashMap<String, String> oldFriend = mFriends.get(i2); if (newFriend == null) { newFriends.add(oldFriend); } else { fullName = oldFriend.get(Entities.FRIEND); spaceIdx = fullName.lastIndexOf(" "); String oldFirstName = null; String oldLastName = null; if (spaceIdx == -1) oldFirstName = fullName; else { oldFirstName = fullName.substring(0, spaceIdx++); oldLastName = fullName.substring(spaceIdx); } if (newFirstName == null) { newFriends.add(newFriend); newFriend = null; } else { int comparison = oldFirstName.compareToIgnoreCase(newFirstName); if (comparison == 0) { // compare firstnames if (newLastName == null) { newFriends.add(newFriend); newFriend = null; } else if (oldLastName != null) { comparison = oldLastName.compareToIgnoreCase(newLastName); if (comparison == 0) { newFriends.add(newFriend); newFriend = null; } else if (comparison > 0) { newFriends.add(newFriend); newFriend = null; } } } else if (comparison > 0) { newFriends.add(newFriend); newFriend = null; } } newFriends.add(oldFriend); } } if (newFriend != null) newFriends.add(newFriend); mFriends = newFriends; } } loadList = true; } catch (JSONException e) { Log.e(TAG, e.toString()); } } break; case MYSPACE: break; case LINKEDIN: break; case FOURSQUARE: break; case IDENTICA: break; case GOOGLEPLUS: break; case CHATTER: break; } return loadList; } @Override protected void onPostExecute(Boolean loadList) { if (loadList) { // SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND}, new int[]{R.id.profile, R.id.name}); SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected }); sa.setViewBinder(mViewBinder); setListAdapter(sa); } if (loadingDialog.isShowing()) loadingDialog.dismiss(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(mAccountId); }