List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:at.general.solutions.android.ical.activity.ICalSynchronizeActivity.java
protected Dialog createSettingsIncompleteDialog(final int dialogId) { AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this).setTitle(getString(R.string.anErrorOccured)) .setMessage(getString(R.string.preferencesIncomplete)).setCancelable(false) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override/* www.java2s .c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.cancel(); removeDialog(dialogId); } }); return dlgBuilder.create(); }
From source file:com.sourcey.materiallogindemo.MainActivity.java
private void MessageDialog(String msg) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(msg).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();// ww w.ja va 2s . c o m } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * Show dialog error// www.j a v a 2 s.c o m * @param errStr */ public void showDialogInformation(String errStr) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setIcon(R.drawable.icon); adb.setTitle(R.string.str_ErrPlay_Title); adb.setMessage(errStr); adb.setPositiveButton(R.string.str_OK, new OnClickListener() { public void onClick(DialogInterface a0, int a1) { return; } }); AlertDialog ad = adb.create(); ad.show(); }
From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java
private void registerWithQRUrl(final String qr_url) { if (!mService.getNetworkConnectivityManager().isConnected()) { UIUtils.showNoNetworkDialog(this); return;/*from w ww .ja v a 2s . co m*/ } final String timestamp = "" + mWiz.getTimestamp(); final String deviceId = mWiz.getDeviceId(); final String registrationId = mWiz.getRegistrationId(); final String installId = mWiz.getInstallationId(); // Make call to Rogerthat webfarm mProgressContainer.setVisibility(View.VISIBLE); mButtonContainer.setVisibility(View.GONE); final SafeRunnable showErrorDialog = new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mProgressContainer.setVisibility(View.GONE); mButtonContainer.setVisibility(View.VISIBLE); AlertDialog.Builder builder = new AlertDialog.Builder(ContentBrandingRegistrationActivity.this); builder.setMessage(R.string.error_please_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } }; mWorkerHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.REGISTRATION(); String version = "1"; String signature = Security.sha256(version + " " + installId + " " + timestamp + " " + deviceId + " " + registrationId + " " + qr_url + CloudConstants.REGISTRATION_MAIN_SIGNATURE); HttpPost httppost = new HttpPost(CloudConstants.REGISTRATION_QR_URL); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(13); nameValuePairs.add(new BasicNameValuePair("version", version)); nameValuePairs.add(new BasicNameValuePair("platform", "android")); nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp)); nameValuePairs.add(new BasicNameValuePair("device_id", deviceId)); nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId)); nameValuePairs.add(new BasicNameValuePair("signature", signature)); nameValuePairs.add(new BasicNameValuePair("install_id", installId)); nameValuePairs.add(new BasicNameValuePair("qr_url", qr_url)); nameValuePairs.add(new BasicNameValuePair("language", Locale.getDefault().getLanguage())); nameValuePairs.add(new BasicNameValuePair("country", Locale.getDefault().getCountry())); nameValuePairs.add(new BasicNameValuePair("app_id", CloudConstants.APP_ID)); nameValuePairs.add( new BasicNameValuePair("use_xmpp_kick", CloudConstants.USE_XMPP_KICK_CHANNEL + "")); nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", mGCMRegistrationId)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = mHttpClient.execute(httppost); int statusCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (entity == null) { mUIHandler.post(showErrorDialog); return; } @SuppressWarnings("unchecked") final Map<String, Object> responseMap = (Map<String, Object>) JSONValue .parse(new InputStreamReader(entity.getContent())); if (statusCode != 200 || responseMap == null) { if (statusCode == 500 && responseMap != null) { final String errorMessage = (String) responseMap.get("error"); if (errorMessage != null) { mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mProgressContainer.setVisibility(View.GONE); mButtonContainer.setVisibility(View.VISIBLE); AlertDialog.Builder builder = new AlertDialog.Builder( ContentBrandingRegistrationActivity.this); builder.setMessage(errorMessage); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } }); return; } } mUIHandler.post(showErrorDialog); return; } JSONObject account = (JSONObject) responseMap.get("account"); final String email = (String) responseMap.get("email"); final RegistrationInfo info = new RegistrationInfo(email, new Credentials((String) account.get("account"), (String) account.get("password"))); mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mWiz.setEmail(email); mWiz.save(); tryConnect(1, getString(R.string.registration_establish_connection, email, getString(R.string.app_name)) + " ", info); } }); } catch (Exception e) { L.d(e); mUIHandler.post(showErrorDialog); } } }); }
From source file:com.df.push.DemoActivity.java
private void displayOptionsToUnbscribe() { if (subscriptions.size() == 0) { Toast.makeText(getApplicationContext(), "No Subscriptions...", Toast.LENGTH_LONG).show(); return;//from ww w. j av a 2s . c om } final CharSequence[] cs = subscriptions.toArray(new CharSequence[subscriptions.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select item to unsubscribe"); builder.setItems(cs, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Do something with the selection unsubscribe(cs[item].toString()); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.yozio.demo.implementations.share.ShareButtonsActivity.java
public void showShareCommentDialog(Context context, final DialogFlowController controller) { final EditText text = new EditText(context); text.setMinLines(5);/* ww w . j a v a 2s.c o m*/ text.setGravity(Gravity.TOP); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Share"); builder.setMessage("Enter a comment (Optional)"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { controller.onContinue(text.getText().toString()); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { controller.onCancel(); } }); AlertDialog dialog = builder.create(); dialog.setView(text); dialog.show(); }
From source file:com.mendhak.gpslogger.common.PrefsIO.java
public Dialog ChooseFileDialog() { File myDir = new File(defPath); if (!myDir.exists()) return null; Utilities.LogDebug("Asking user the file to use for import of settings"); File[] enumeratedFiles = myDir.listFiles(new FilenameFilter() { @Override/* w w w . ja v a 2 s .c o m*/ public boolean accept(File dir, String name) { return name.endsWith("." + extension); } }); final int len = enumeratedFiles.length; List<String> fileList = new ArrayList<String>(len); for (File f : enumeratedFiles) { fileList.add(f.getName()); } fileList.add(context.getString(R.string.Browse)); final String[] files = fileList.toArray(new String[fileList.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(R.string.SelectFile)); builder.setItems(files, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (item < len) { curFileName = defPath + File.separator + files[item]; ImportFile(); } else BrowseFile(); } }); builder.setCancelable(true); return builder.create(); }
From source file:com.mobicage.rogerthat.registration.YSAAARegistrationActivity.java
private void register() { mStatusLbl.setText(R.string.initializing); mProgressBar.setProgress(0);/*ww w .j av a 2 s.c om*/ mProgressBar.setVisibility(View.VISIBLE); TimerTask timerTask = new TimerTask() { @Override public void run() { mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mProgressBar.setProgress(mProgressBar.getProgress() + 1); } }); } }; mTimer.scheduleAtFixedRate(timerTask, 250, 250); mRetryBtn.setVisibility(View.GONE); if (!mService.getNetworkConnectivityManager().isConnected()) { mTimer.cancel(); mProgressBar.setVisibility(View.GONE); mStatusLbl.setText(R.string.registration_screen_instructions_check_network_not_available); mRetryBtn.setVisibility(View.VISIBLE); UIUtils.showNoNetworkDialog(this); return; } final SafeRunnable showErrorDialog = new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); AlertDialog.Builder builder = new AlertDialog.Builder(YSAAARegistrationActivity.this); builder.setMessage(R.string.error_please_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); mTimer.cancel(); mProgressBar.setVisibility(View.GONE); mStatusLbl.setText(R.string.error_please_try_again); mRetryBtn.setVisibility(View.VISIBLE); } }; final String timestamp = "" + mWiz.getTimestamp(); final String deviceId = mWiz.getDeviceId(); final String registrationId = mWiz.getRegistrationId(); final String installId = mWiz.getInstallationId(); mWorkerHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.REGISTRATION(); String version = "1"; String signature = Security.sha256( version + " " + installId + " " + timestamp + " " + deviceId + " " + registrationId + " " + CloudConstants.APP_SERVICE_GUID + CloudConstants.REGISTRATION_MAIN_SIGNATURE); HttpPost httppost = new HttpPost(CloudConstants.REGISTRATION_YSAAA_URL); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(13); nameValuePairs.add(new BasicNameValuePair("version", version)); nameValuePairs.add(new BasicNameValuePair("platform", "android")); nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp)); nameValuePairs.add(new BasicNameValuePair("device_id", deviceId)); nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId)); nameValuePairs.add(new BasicNameValuePair("signature", signature)); nameValuePairs.add(new BasicNameValuePair("install_id", installId)); nameValuePairs.add(new BasicNameValuePair("service", CloudConstants.APP_SERVICE_GUID)); nameValuePairs.add(new BasicNameValuePair("language", Locale.getDefault().getLanguage())); nameValuePairs.add(new BasicNameValuePair("country", Locale.getDefault().getCountry())); nameValuePairs.add(new BasicNameValuePair("app_id", CloudConstants.APP_ID)); nameValuePairs.add( new BasicNameValuePair("use_xmpp_kick", CloudConstants.USE_XMPP_KICK_CHANNEL + "")); nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", mGCMRegistrationId)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = mHttpClient.execute(httppost); int statusCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (entity == null) { mUIHandler.post(showErrorDialog); return; } @SuppressWarnings("unchecked") final Map<String, Object> responseMap = (Map<String, Object>) JSONValue .parse(new InputStreamReader(entity.getContent())); if (statusCode != 200 || responseMap == null) { if (statusCode == 500 && responseMap != null) { final String errorMessage = (String) responseMap.get("error"); if (errorMessage != null) { mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); AlertDialog.Builder builder = new AlertDialog.Builder( YSAAARegistrationActivity.this); builder.setMessage(errorMessage); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); mTimer.cancel(); mProgressBar.setVisibility(View.GONE); mStatusLbl.setText(errorMessage); mRetryBtn.setVisibility(View.VISIBLE); } }); return; } } mUIHandler.post(showErrorDialog); return; } JSONObject account = (JSONObject) responseMap.get("account"); final String email = (String) responseMap.get("email"); final RegistrationInfo info = new RegistrationInfo(email, new Credentials((String) account.get("account"), (String) account.get("password"))); mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mWiz.setEmail(email); mWiz.save(); tryConnect(1, getString(R.string.registration_establish_connection, email, getString(R.string.app_name)) + " ", info); } }); } catch (Exception e) { L.d(e); mUIHandler.post(showErrorDialog); } } }); }
From source file:geert.stef.sm.beheerautokm.AddRitActivity.java
public void showAddedDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Added").setMessage("The number is added.").setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //do some thing here which you need }/* w w w. ja v a 2s . c o m*/ }); /*builder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } });*/ AlertDialog alert = builder.create(); alert.show(); }
From source file:net.coding.program.project.init.create.ProjectCreateFragment.java
@Click void projectIcon() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("").setCancelable(true).setItems(R.array.camera_gallery, new DialogInterface.OnClickListener() { @Override/*w w w . j av a 2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { if (which == 0) { camera(); } else { photo(); } } }); AlertDialog dialog = builder.create(); dialog.show(); CustomDialog.dialogTitleLineColor(getActivity(), dialog); }