List of usage examples for android.app AlertDialog.Builder setCancelable
public void setCancelable(boolean flag)
From source file:com.lge.friendsCamera.Utils.java
public static void showAlertDialog(Context context, String title, String message, DialogInterface.OnClickListener posListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title);/*w w w .j a va 2s. c om*/ alert.setMessage(message); alert.setPositiveButton("Ok", posListener); alert.setCancelable(false); alert.show(); }
From source file:com.lge.friendsCamera.Utils.java
public static void showSelectDialog(Context context, String title, String message, DialogInterface.OnClickListener positiveListener, DialogInterface.OnClickListener cancelListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title);/*from w w w . j ava2 s. com*/ alert.setMessage(message); alert.setPositiveButton("Ok", positiveListener); alert.setNegativeButton("Cancel", cancelListener); alert.setCancelable(false); alert.show(); }
From source file:org.cinedroid.util.CineworldAPIAssistant.java
/** * Create a dialog with the text "Problem connecting to the Cineworld API", with two buttons, "Retry", which will re run the task, and * "Back" which will close the owningActivity. * //from ww w .j ava 2 s . com * @param owningActivity * @param task */ public static void createCineworldAPIErrorDialog(final Activity owningActivity, final ResurrectableTask task) { AlertDialog.Builder builder = new AlertDialog.Builder(owningActivity); builder.setMessage("Problem connecting to the Cineworld API"); builder.setCancelable(false); builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { task.resurrect(); } }); builder.setNegativeButton("Back", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { owningActivity.finish(); } }); builder.create().show(); }
From source file:org.ubicompforall.cityexplorer.gui.ImportWebTab.java
/** * Display a dialog for explaining the user the process of downloading a database. *//* w ww. j ava 2 s.co m*/ private static void showDownloadDialog(Activity context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setMessage(R.string.download_dialog); builder.setTitle(R.string.download_dialog_title); builder.setPositiveButton(R.string.download_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); builder.show(); }
From source file:com.codyy.rx.permissions.RxPermissions.java
/** * ??,????//from www. j a va 2 s.com * * @param context context * @param packageName ?? * @param message ??? */ public static void showDialog(@NonNull final Context context, @NonNull final String packageName, @NonNull String message) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("??").setMessage(message); builder.setCancelable(true); builder.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { openPermissionSettings(context, packageName); } }).setNegativeButton("?", null).create().show(); }
From source file:jp.ne.sakura.kkkon.android.exceptionhandler.DefaultUploaderWeb.java
public static void upload(final Context context, final File file, final String url) { terminate();/*w ww. ja va2s. com*/ thread = new Thread(new Runnable() { @Override public void run() { Log.d(TAG, "upload thread tid=" + android.os.Process.myTid()); try { //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS) Log.d(TAG, "fng=" + Build.FINGERPRINT); final List<NameValuePair> list = new ArrayList<NameValuePair>(16); list.add(new BasicNameValuePair("fng", Build.FINGERPRINT)); HttpPost httpPost = new HttpPost(url); //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) ); httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); DefaultHttpClient httpClient = new DefaultHttpClient(); Log.d(TAG, "socket.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(5 * 1000)); httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(5 * 1000)); Log.d(TAG, "socket.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); // <uses-permission android:name="android.permission.INTERNET"/> // got android.os.NetworkOnMainThreadException, run at UI Main Thread HttpResponse response = httpClient.execute(httpPost); Log.d(TAG, "response=" + response.getStatusLine().getStatusCode()); } catch (Exception e) { Log.d(TAG, "got Exception. msg=" + e.getMessage(), e); } finally { ExceptionHandler.clearReport(); } Log.d(TAG, "upload finish"); } }); thread.setName("upload crash"); thread.start(); if (USE_DIALOG) { final AlertDialog.Builder alertDialogBuilder = setupAlertDialog(context); if (null != alertDialogBuilder) { alertDialogBuilder.setCancelable(false); final AlertDialog alertDialog = alertDialogBuilder.show(); /* while ( thread.isAlive() ) { Log.d( TAG, "thread tid=" + android.os.Process.myTid() + ",state=" + thread.getState() ); if ( ! thread.isAlive() ) { break; } { try { Thread.sleep( 1 * 1000 ); } catch ( InterruptedException e ) { Log.d( TAG, "got exception", e ); } } if ( null != alertDialog ) { if ( alertDialog.isShowing() ) { } else { if ( ! thread.isAlive() ) { break; } alertDialog.show(); } } if ( ! Thread.State.RUNNABLE.equals(thread.getState()) ) { break; } } if ( null != alertDialog ) { alertDialog.dismiss(); } */ } try { thread.join(); // must call. leak handle... thread = null; } catch (InterruptedException e) { Log.d(TAG, "got Exception", e); } } }
From source file:com.doplgangr.secrecy.utils.Util.java
public static void alert(final Context context, final String title, final String message, final DialogInterface.OnClickListener ok) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override//from w ww . jav a2 s . co m public void run() { AlertDialog.Builder a = new AlertDialog.Builder(context); if (title != null) a.setTitle(title); if (message != null) a.setMessage(message); if (ok != null) a.setPositiveButton("OK", ok); a.setCancelable(false); a.show(); } }); }
From source file:org.ubicompforall.cityexplorer.CityExplorer.java
/** * Display a dialog that user has no Internet connection * Code from: http://osdir.com/ml/Android-Developers/2009-11/msg05044.html * @return // www . j av a 2 s . c om */ public static AlertDialog showNoConnectionDialog(final Context myContext, final String msg, final String cancelButtonStr, final Intent cancelIntent) { AlertDialog.Builder builder = new AlertDialog.Builder(myContext); builder.setCancelable(true); if (msg == "") { builder.setMessage(R.string.no_connection); } else { builder.setMessage(msg); } builder.setTitle(R.string.no_connection_title); builder.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { myContext.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } }); String cancelText = cancelButtonStr; if (cancelText == "") { cancelText = myContext.getResources().getString(R.string.cancel); } builder.setNegativeButton(cancelText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (cancelIntent != null) { if (myContext instanceof Activity) { ((Activity) myContext).startActivityForResult(cancelIntent, CityExplorer.REQUEST_LOCATION); } else { debug(-1, "This is not an Activity!!"); } dialog.dismiss(); } return; } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { if (myContext == null) { debug(0, "OOOPS!"); } else { Toast.makeText(myContext, "CANCELLED!", Toast.LENGTH_LONG).show(); if (cancelIntent != null) { myContext.startActivity(cancelIntent); } } return; } }); DATACONNECTION_NOTIFIED = true; return builder.show(); }
From source file:de.ub0r.android.lib.DonationHelper.java
/** * Show "donate" dialog./*from ww w .j a v a2 s .co m*/ * * @param context * {@link Context} * @param title * title * @param btnDonate * button text for donate * @param btnNoads * button text for "i did a donation" * @param messages * messages for dialog body */ public static void showDonationDialog(final Activity context, final String title, final String btnDonate, final String btnNoads, final String[] messages) { final Intent marketIntent = Market.getInstallAppIntent(context, DONATOR_PACKAGE, null); String btnTitle = String.format(btnDonate, "Play Store"); SpannableStringBuilder sb = new SpannableStringBuilder(); for (String m : messages) { sb.append(m); sb.append("\n"); } sb.delete(sb.length() - 1, sb.length()); sb.setSpan(new RelativeSizeSpan(0.75f), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); AlertDialog.Builder b = new AlertDialog.Builder(context); b.setTitle(title); b.setMessage(sb); b.setCancelable(true); b.setPositiveButton(btnTitle, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { try { context.startActivity(marketIntent); } catch (ActivityNotFoundException e) { Log.e(TAG, "activity not found", e); Toast.makeText(context, "activity not found", Toast.LENGTH_LONG).show(); } } }); b.setNeutralButton(btnNoads, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( "http://code.google.com/p/ub0rapps/downloads/list?" + "can=3&q=Product%3DDonator"))); } catch (ActivityNotFoundException e) { Log.e(TAG, "activity not found", e); Toast.makeText(context, "activity not found", Toast.LENGTH_LONG).show(); } } }); b.show(); }
From source file:Main.java
public static void getRingtonesDialog(Activity activity, Collection<String> items, int selected, DialogInterface.OnClickListener itemClickListener, DialogInterface.OnClickListener okClickListener, final DialogInterface.OnClickListener cancelClickListener) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(activity); builderSingle.setTitle("Select Ringtone"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, android.R.layout.select_dialog_singlechoice); arrayAdapter.addAll(items);//from ww w.j a v a 2 s .c o m builderSingle.setNegativeButton(android.R.string.cancel, cancelClickListener); builderSingle.setPositiveButton(android.R.string.ok, okClickListener); builderSingle.setSingleChoiceItems(arrayAdapter, selected, itemClickListener); builderSingle.setCancelable(false); builderSingle.show(); }