List of usage examples for android.app AlertDialog show
public void show()
From source file:dev.ukanth.ufirewall.Api.java
public static void alertDialog(final Context ctx, String msgText) { if (ctx != null) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(msgText).setCancelable(false).setPositiveButton(ctx.getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); }//from www . ja va2s. c o m }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:dev.ukanth.ufirewall.Api.java
public static void saveSharedPreferencesToFileConfirm(final Context ctx) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(ctx.getString(R.string.exportConfirm)).setCancelable(false) .setPositiveButton(ctx.getString(R.string.Yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (saveSharedPreferencesToFile(ctx)) { Api.alert(ctx, ctx.getString(R.string.export_rules_success) + " " + Environment.getExternalStorageDirectory().getPath() + "/afwall/"); } else { Api.alert(ctx, ctx.getString(R.string.export_rules_fail)); }// w w w.j av a 2s. co m } }).setNegativeButton(ctx.getString(R.string.No), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:dev.ukanth.ufirewall.Api.java
public static void saveAllPreferencesToFileConfirm(final Context ctx) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(ctx.getString(R.string.exportConfirm)).setCancelable(false) .setPositiveButton(ctx.getString(R.string.Yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (saveAllPreferencesToFile(ctx)) { Api.alert(ctx, ctx.getString(R.string.export_rules_success) + " " + Environment.getExternalStorageDirectory().getPath() + "/afwall/"); } else { Api.alert(ctx, ctx.getString(R.string.export_rules_fail)); }//from ww w. ja v a2 s.com } }).setNegativeButton(ctx.getString(R.string.No), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.romanenco.gitt.BrowserActivity.java
private void deleteThisRepo() { AlertDialog dlg = new AlertDialog.Builder(this).setMessage(R.string.confirm_repo_delete) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DAO dao = new DAO(BrowserActivity.this); dao.open(true);// w w w .ja v a 2 s. c o m dao.delete(current.getFolder()); dao.close(); Intent delete = new Intent(BrowserActivity.this, GitService.class); delete.putExtra(GitService.COMMAND, GitService.Command.Delete); delete.putExtra(GitService.REPO, current); startService(delete); Intent main = new Intent(BrowserActivity.this, MainActivity.class); main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(main); } }).setNegativeButton(getString(android.R.string.cancel), null).create(); dlg.setCanceledOnTouchOutside(false); dlg.show(); }
From source file:com.ibuildapp.romanblack.WebPlugin.WebPlugin.java
@Override public void create() { try {//from w w w .j a v a 2 s.com setContentView(R.layout.romanblack_html_main); root = (FrameLayout) findViewById(R.id.romanblack_root_layout); webView = new ObservableWebView(this); webView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); root.addView(webView); webView.setHorizontalScrollBarEnabled(false); setTitle("HTML"); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } appName = widget.getAppName(); if (widget.getPluginXmlData().length() == 0) { if (currentIntent.getStringExtra("WidgetFile").length() == 0) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } } if (widget.getTitle() != null && widget.getTitle().length() > 0) { setTopBarTitle(widget.getTitle()); } else { setTopBarTitle(getResources().getString(R.string.romanblack_html_web)); } currentUrl = (String) getSession(); if (currentUrl == null) { currentUrl = ""; } ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isConnectedOrConnecting()) { isOnline = true; } // topbar initialization setTopBarLeftButtonText(getString(R.string.common_home_upper), true, new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); if (isOnline) { webView.getSettings().setJavaScriptEnabled(true); } webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.getSettings().setGeolocationEnabled(true); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setUseWideViewPort(false); webView.getSettings().setSavePassword(false); webView.clearHistory(); webView.invalidate(); if (Build.VERSION.SDK_INT >= 19) { } webView.getSettings().setUserAgentString( "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"); webView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.invalidate(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { } break; case MotionEvent.ACTION_UP: { if (!v.hasFocus()) { v.requestFocus(); } } break; case MotionEvent.ACTION_MOVE: { } break; } return false; } }); webView.setBackgroundColor(Color.WHITE); try { if (widget.getBackgroundColor() != Color.TRANSPARENT) { webView.setBackgroundColor(widget.getBackgroundColor()); } } catch (IllegalArgumentException e) { } webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); } }); webView.setWebChromeClient(new WebChromeClient() { FrameLayout.LayoutParams LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); @Override public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this); builder.setTitle(R.string.location_dialog_title); builder.setMessage(R.string.location_dialog_description); builder.setCancelable(true); builder.setPositiveButton(R.string.location_dialog_allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.invoke(origin, true, false); } }); builder.setNegativeButton(R.string.location_dialog_not_allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.invoke(origin, false, false); } }); AlertDialog alert = builder.create(); alert.show(); } @Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { if (customView != null) { customViewCallback.onCustomViewHidden(); return; } view.setBackgroundColor(Color.BLACK); view.setLayoutParams(LayoutParameters); root.addView(view); customView = view; customViewCallback = callback; webView.setVisibility(View.GONE); } @Override public void onHideCustomView() { if (customView == null) { return; } else { closeFullScreenVideo(); } } public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT);//Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); isMedia = true; startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } //For Android 4.1 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); isMedia = true; i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } @Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { isV21 = true; mUploadMessageV21 = filePathCallback; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); return true; } @Override public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) { super.onReceivedTouchIconUrl(view, url, precomposed); } }); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (state == states.EMPTY) { currentUrl = url; setSession(currentUrl); state = states.LOAD_START; handler.sendEmptyMessage(SHOW_PROGRESS); } } @Override public void onLoadResource(WebView view, String url) { if (!alreadyLoaded && (url.startsWith("http://www.youtube.com/get_video_info?") || url.startsWith("https://www.youtube.com/get_video_info?")) && Build.VERSION.SDK_INT < 11) { try { String path = url.contains("https://www.youtube.com/get_video_info?") ? url.replace("https://www.youtube.com/get_video_info?", "") : url.replace("http://www.youtube.com/get_video_info?", ""); String[] parqamValuePairs = path.split("&"); String videoId = null; for (String pair : parqamValuePairs) { if (pair.startsWith("video_id")) { videoId = pair.split("=")[1]; break; } } if (videoId != null) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse("http://www.youtube.com/watch?v=" + videoId))); needRefresh = true; alreadyLoaded = !alreadyLoaded; return; } } catch (Exception ex) { } } else { super.onLoadResource(view, url); } } @Override public void onPageFinished(WebView view, String url) { if (hideProgress) { if (TextUtils.isEmpty(WebPlugin.this.url)) { state = states.LOAD_COMPLETE; handler.sendEmptyMessage(HIDE_PROGRESS); super.onPageFinished(view, url); } else { view.loadUrl("javascript:(function(){" + "l=document.getElementById('link');" + "e=document.createEvent('HTMLEvents');" + "e.initEvent('click',true,true);" + "l.dispatchEvent(e);" + "})()"); hideProgress = false; } } else { state = states.LOAD_COMPLETE; handler.sendEmptyMessage(HIDE_PROGRESS); super.onPageFinished(view, url); } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { if (errorCode == WebViewClient.ERROR_BAD_URL) { startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), DOWNLOAD_REQUEST_CODE); } } @Override public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { final AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this); builder.setMessage(R.string.notification_error_ssl_cert_invalid); builder.setPositiveButton(WebPlugin.this.getResources().getString(R.string.wp_continue), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.proceed(); } }); builder.setNegativeButton(WebPlugin.this.getResources().getString(R.string.wp_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onFormResubmission(WebView view, Message dontResend, Message resend) { super.onFormResubmission(view, dontResend, resend); } @Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { return super.shouldInterceptRequest(view, request); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try { if (url.contains("youtube.com/watch")) { if (Build.VERSION.SDK_INT < 11) { try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse(url))); return true; } catch (Exception ex) { return false; } } else { return false; } } else if (url.contains("paypal.com")) { if (url.contains("&bn=ibuildapp_SP")) { return false; } else { url = url + "&bn=ibuildapp_SP"; webView.loadUrl(url); return true; } } else if (url.contains("sms:")) { try { Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setData(Uri.parse(url)); startActivity(smsIntent); return true; } catch (Exception ex) { Log.e("", ex.getMessage()); return false; } } else if (url.contains("tel:")) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(url)); startActivity(callIntent); return true; } else if (url.contains("mailto:")) { MailTo mailTo = MailTo.parse(url); Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { mailTo.getTo() }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mailTo.getSubject()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, mailTo.getBody()); WebPlugin.this.startActivity(Intent.createChooser(emailIntent, getString(R.string.romanblack_html_send_email))); return true; } else if (url.contains("rtsp:")) { Uri address = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, address); final PackageManager pm = getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); if (matches.size() > 0) { startActivity(intent); } else { Toast.makeText(WebPlugin.this, getString(R.string.romanblack_html_no_video_player), Toast.LENGTH_SHORT).show(); } return true; } else if (url.startsWith("intent:") || url.startsWith("market:") || url.startsWith("col-g2m-2:")) { Intent it = new Intent(); it.setData(Uri.parse(url)); startActivity(it); return true; } else if (url.contains("//play.google.com/")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } else { if (url.contains("ibuildapp.com-1915109")) { String param = Uri.parse(url).getQueryParameter("widget"); finish(); if (param != null && param.equals("1001")) com.appbuilder.sdk.android.Statics.launchMain(); else if (param != null && !"".equals(param)) { View.OnClickListener widget = Statics.linkWidgets.get(Integer.valueOf(param)); if (widget != null) widget.onClick(view); } return false; } currentUrl = url; setSession(currentUrl); if (!isOnline) { handler.sendEmptyMessage(HIDE_PROGRESS); handler.sendEmptyMessage(STOP_LOADING); } else { String pageType = "application/html"; if (!url.contains("vk.com")) { getPageType(url); } if (pageType.contains("application") && !pageType.contains("html") && !pageType.contains("xml")) { startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), DOWNLOAD_REQUEST_CODE); return super.shouldOverrideUrlLoading(view, url); } else { view.getSettings().setLoadWithOverviewMode(true); view.getSettings().setUseWideViewPort(true); view.setBackgroundColor(Color.WHITE); } } return false; } } catch (Exception ex) { // Error Logging return false; } } }); handler.sendEmptyMessage(SHOW_PROGRESS); new Thread() { @Override public void run() { EntityParser parser; if (widget.getPluginXmlData() != null) { if (widget.getPluginXmlData().length() > 0) { parser = new EntityParser(widget.getPluginXmlData()); } else { String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } } else { String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } parser.parse(); url = parser.getUrl(); html = parser.getHtml(); if (url.length() > 0 && !isOnline) { handler.sendEmptyMessage(NEED_INTERNET_CONNECTION); } else { if (isOnline) { } else { if (html.length() == 0) { } } if (html.length() > 0 || url.length() > 0) { handler.sendEmptyMessageDelayed(SHOW_HTML, 700); } else { handler.sendEmptyMessage(HIDE_PROGRESS); handler.sendEmptyMessage(INITIALIZATION_FAILED); } } } }.start(); } catch (Exception ex) { } }
From source file:com.vk.sdk.VKCaptchaDialog.java
/** * Prepare, create and show dialog for displaying captcha *///from w w w .j a v a 2 s . co m public void show() { Context context = VKUIHelper.getTopActivity(); View innerView = LayoutInflater.from(context).inflate(R.layout.dialog_vkcaptcha, null); assert innerView != null; mCaptchaAnswer = (EditText) innerView.findViewById(R.id.captchaAnswer); mCaptchaImage = (ImageView) innerView.findViewById(R.id.imageView); mProgressBar = (ProgressBar) innerView.findViewById(R.id.progressBar); mDensity = context.getResources().getDisplayMetrics().density; final AlertDialog dialog = new AlertDialog.Builder(context).setView(innerView).create(); mCaptchaAnswer.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); mCaptchaAnswer.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { if (actionId == EditorInfo.IME_ACTION_SEND) { sendAnswer(); return true; } return false; } }); dialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { sendAnswer(); } }); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { mCaptchaError.request.cancel(); } }); loadImage(); dialog.show(); }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
public void setErrorDialog() { // ?? ? ?/*from w ww .j a va 2 s .c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(this); // ?? ? builder.setMessage(getString(DataView.CONNECTION_ERROR_DIALOG_TEXT)); builder.setCancelable(false); // ? ? /*Retry*/ builder.setPositiveButton(DataView.CONNECTION_ERROR_DIALOG_BUTTON1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { fError = false; //TODO improve try { repaint(); // ? } catch (Exception ex) { // ? doError(ex); } } }); /*Open settings*/ builder.setNeutralButton(DataView.CONNECTION_ERROR_DIALOG_BUTTON2, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // ?? Intent intent1 = new Intent(Settings.ACTION_WIRELESS_SETTINGS); startActivityForResult(intent1, 42); } }); /*Close application*/ builder.setNegativeButton(DataView.CONNECTION_ERROR_DIALOG_BUTTON3, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { System.exit(0); // ? } }); AlertDialog alert = builder.create(); alert.show(); // ? }
From source file:com.appdupe.flamer.LoginUsingFacebook.java
private void showGPSDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("GPS is disabled in your device. Would you like to enable it?") .setCancelable(false).setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();//from w ww. j a v a2 s .com Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(callGPSSettingIntent); } }); alertDialogBuilder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); finish(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
/** * Manage click on GameSet.//from w w w . ja v a 2s . c o m * * @param pos */ private void onListItemClick(final int pos) { final GameSet gameSet = (GameSet) getListAdapter().getItem(pos); final Item[] items = AppContext.getApplication().isAppLimited() ? limitedItems : allItems; ListAdapter adapter = new ArrayAdapter<Item>(this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @Override public View getView(int position, View convertView, ViewGroup parent) { // User super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); // Put the image on the TextView tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); // Add margin between image and text (support various screen // densities) int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format(this.getString(R.string.lblGameSetHistoryActivityMenuTitle), new SimpleDateFormat("dd/MM/yy").format(gameSet.getCreationTs()))); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int itemIndex) { Item item = items[itemIndex]; if (item.itemType == Item.ItemTypes.publishOnFacebook) { // check for active internet connexion first // see post // http://stackoverflow.com/questions/2789612/how-can-i-check-whether-an-android-device-is-connected-to-the-web ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { if (gameSet.getGameCount() == 0) { Toast.makeText(GameSetHistoryActivity.this, R.string.lblFacebookImpossibleToPublishGamesetWithNoGame, Toast.LENGTH_SHORT) .show(); } else if (!AppContext.getApplication().getNotificationIds().isEmpty()) { Toast.makeText(GameSetHistoryActivity.this, R.string.lblFacebookGamesetBeingPublished, Toast.LENGTH_SHORT).show(); } else { tempGameSet = gameSet; // // TODO Improve in later version // ShortenUrlTask shortenUrlTask = new // ShortenUrlTask(FacebookHelper.buildGameSetUrl(tempGameSet)); // shortenUrlTask.setCallback(urlShortenedCallback); // shortenUrlTask.execute(); startPostProcess(); } } else { Toast.makeText(GameSetHistoryActivity.this, getString(R.string.titleInternetConnexionNecessary), Toast.LENGTH_LONG).show(); } } else if (item.itemType == Item.ItemTypes.publishOnTwitter) { Toast.makeText(GameSetHistoryActivity.this, "TODO: Publish on twitter", Toast.LENGTH_LONG) .show(); Intent intent = new Intent(GameSetHistoryActivity.this, TwitterConnectActivity.class); startActivity(intent); } else if (item.itemType == Item.ItemTypes.remove) { RemoveGameSetDialogClickListener removeGameSetDialogClickListener = new RemoveGameSetDialogClickListener( gameSet); AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.titleRemoveGameSetYesNo)); builder.setMessage(Html.fromHtml( GameSetHistoryActivity.this.getText(R.string.msgRemoveGameSetYesNo).toString())); builder.setPositiveButton(GameSetHistoryActivity.this.getString(R.string.btnOk), removeGameSetDialogClickListener); builder.setNegativeButton(GameSetHistoryActivity.this.getString(R.string.btnCancel), removeGameSetDialogClickListener).show(); builder.setIcon(android.R.drawable.ic_dialog_alert); } else if (item.itemType == Item.ItemTypes.transferOverBluetooth) { if (!GameSetHistoryActivity.this.bluetoothHelper.isBluetoothEnabled()) { Toast.makeText(GameSetHistoryActivity.this, GameSetHistoryActivity.this.getString(R.string.msgActivateBluetooth), Toast.LENGTH_LONG).show(); } try { // make sure at least one device was discovered if (GameSetHistoryActivity.this.bluetoothHelper.getBluetoothDeviceCount() == 0) { Toast.makeText(GameSetHistoryActivity.this, GameSetHistoryActivity.this.getString(R.string.msgRunDiscoverDevicesFirst), Toast.LENGTH_LONG).show(); } // display devices and download final String[] items = GameSetHistoryActivity.this.bluetoothHelper .getBluetoothDeviceNames(); AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.lblSelectBluetoothDevice)); builder.setItems(items, new BluetoothDeviceClickListener(gameSet, items)); AlertDialog alert = builder.create(); alert.show(); } catch (Exception e) { AuditHelper.auditError(ErrorTypes.gameSetHistoryActivityError, e, GameSetHistoryActivity.this); } } else if (item.itemType == Item.ItemTypes.exportToExcel) { try { if (!AppContext.getApplication().isAppLimited()) { ExportToExcelTask task = new ExportToExcelTask(GameSetHistoryActivity.this, progressDialog); task.setCallback(excelExportCallback); task.execute(gameSet); } } catch (Exception e) { Toast.makeText( GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getText(R.string.msgGameSetExportError).toString() + e.getMessage(), Toast.LENGTH_LONG).show(); AuditHelper.auditError(ErrorTypes.excelFileStorage, e); } } else if (item.itemType == Item.ItemTypes.edit) { // SharedPreferences preferences = // PreferenceManager.getDefaultSharedPreferences(GameSetHistoryActivity.this); // set selected gameset as session gameset // AppContext.getApplication().getBizService().setGameSet(gameSet); // // Get non DAL stored parameters property from shared // preferences // UIHelper.fillNonComputationPreferences(gameSet.getGameSetParameters(), // preferences); // start tab gameset activity Intent intent = new Intent(GameSetHistoryActivity.this, TabGameSetActivity.class); intent.putExtra(ActivityParams.PARAM_GAMESET_ID, gameSet.getId()); GameSetHistoryActivity.this.startActivityForResult(intent, RequestCodes.DISPLAY_WITH_FACEBOOK); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.appdupe.flamer.LoginUsingFacebook.java
private void ErrorMessageLocationNotFonr(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(LoginUsingFacebook.this); builder.setTitle(title);/*from w w w . ja v a 2s .c o m*/ builder.setMessage(message); builder.setPositiveButton(getResources().getString(R.string.okbuttontext), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.setCancelable(false); alert.show(); }