List of usage examples for android.app AlertDialog.Builder setCancelable
public void setCancelable(boolean flag)
From source file:fr.pasteque.client.Configure.java
/** * Display an AlertDialog/* w w w . j a v a 2 s.c om*/ * Based on Error.showError() but Configuration is not a TrackedActivity * * @param message to display */ private void showError(String message) { AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.error_title); b.setMessage(message); b.setIcon(android.R.drawable.ic_dialog_alert); b.setCancelable(true); b.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Configure.this.invalidateError(); } }); b.show(); }
From source file:br.com.sigacon.coletaDados.FragmentParcelasTabsPager.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); setTitle(R.string.dados_parcela);//from w w w .ja v a 2 s.co m ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabsAdapter.addTab(mTabHost.newTabSpec("maps").setIndicator(getString(R.string.mapa)), FragmentParcelasMap.CountingFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("form").setIndicator(getString(R.string.formulario_parcela)), FragmentParcelasForm.CountingFragment.class, null); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } new Handler().postDelayed(new Runnable() { @Override public void run() { String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); //Se vier null ou length == 0 por que o GPS esta desabilitado. Log.e("sigaLog", "provider " + String.valueOf(provider == null) + " ou " + ((provider.contains("gps")) ? provider : "not Gps")); if (provider == null || !provider.contains("gps")) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( FragmentParcelasTabsPager.this); // Seta o Titulo do Dialog alertDialogBuilder.setTitle(R.string.atencao); Log.e("sigaLog", "alertDialogBuilder.setTitle"); // seta a mensagem alertDialogBuilder.setMessage(R.string.gps_desativado); alertDialogBuilder.setCancelable(false) .setPositiveButton(R.string.sim, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //Para abrir a tela do menu pode fazer assim: Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 1); } }).setNegativeButton(R.string.nao, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // Cria o alertDialog com o conteudo do alertDialogBuilder AlertDialog alertDialog = alertDialogBuilder.create(); Log.e("sigaLog", "alertDialog.create"); // Exibe o Dialog alertDialog.show(); Log.e("sigaLog", "alertDialog.show"); } } }, 1000); }
From source file:com.flowzr.activity.Report2DChartActivity.java
/** * Alert message to warn that there is no filter available (no category, no project, no account or no location) * @param message Message warning the lack of filters by report type. *///from w ww .j a v a 2 s . com private void alertNoFilter(String message) { AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this.getActivity()); dlgAlert.setMessage(message); dlgAlert.setTitle(R.string.reports); dlgAlert.setPositiveButton(R.string.ok, null); dlgAlert.setCancelable(true); dlgAlert.create().show(); }
From source file:com.cttapp.bby.mytlc.layer8apps.MyTlc.java
/************ * PURPOSE: This creates a dialog for our user to choose their * calendar from./*from w w w.ja va 2 s . c o m*/ * ARGUMENTS: String[][] * RETURNS: boolean * TRUE: We successfully created a calendar dialog * FALSE: We failed to create a calendar dialog * AUTHOR: Devin Collins <agent14709@gmail.com> *************/ private boolean createCalendarDialog(final String[][] calendars) { try { // Get the names for each calendar String names[] = new String[calendars.length]; for (int i = 0; i < calendars.length; i++) { names[i] = calendars[i][1]; } // Create a new alert dialog and set the options AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose a calendar"); builder.setCancelable(true); builder.setSingleChoiceItems(names, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialoginterface, int i) { // When we choose a calendar, get the ID and then get the events calID = Integer.parseInt(calendars[i][0]); dialoginterface.dismiss(); runEvents(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } catch (Exception e) { return false; } }
From source file:com.cloudkick.NodeViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.do_connectbot: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String user = prefs.getString("sshUser", "root"); Integer port = new Integer(prefs.getString("sshPort", "22")); String uri = "ssh://" + user + "@" + node.ipAddress + ":" + port + "/#" + user; Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); try {/* w ww .j av a 2 s . c o m*/ startActivity(i); } catch (ActivityNotFoundException e) { // Suggest ConnectBot AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("SSH Client Not Found"); String mfaMessage = ("The ConnectBot SSH Client is required to complete this operation. " + "Would you like to install ConnectBot from the Android Market now?"); builder.setMessage(mfaMessage); builder.setCancelable(true); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent marketActivity = new Intent(Intent.ACTION_VIEW); marketActivity.setData(Uri.parse("market://details?id=org.connectbot")); startActivity(marketActivity); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog mfaDialog = builder.create(); mfaDialog.show(); } return true; default: // If its not recognized, do nothing return super.onOptionsItemSelected(item); } }
From source file:com.sakisds.icymonitor.fragments.graph.GraphContainerFragment.java
/** * Shows an error dialog// ww w . j ava 2 s . co m * * @param error */ protected void showErrorDialog(int error) { AlertDialog.Builder dlgAlert = new AlertDialog.Builder(getActivity()); dlgAlert.setMessage(getResources().getString(error)); dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dlgAlert.setCancelable(true); dlgAlert.create().show(); }
From source file:com.microsoft.projectoxford.face.samples.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); isSmsPermissionGranted();/*from ww w . j a v a 2 s . c o m*/ final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); String userName = settings.getString("userName", ""); String password = settings.getString("password", ""); passwordField = (EditText) findViewById(R.id.passwordFieldText); userNameField = (EditText) findViewById(R.id.userNameFieldText); forgot_password = (TextView) findViewById(R.id.forgot_password); passwordField.setText(password); userNameField.setText(userName); signButton = (ImageButton) findViewById(R.id.signButton); registerNowButton = (ImageButton) findViewById(R.id.registerButton); helloGuest = (TextView) findViewById(R.id.helloGuestLable); logo = (ImageView) findViewById(R.id.logo); progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.progress_dialog_title)); userNameField.setImeActionLabel("", EditorInfo.IME_ACTION_NEXT); userNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { if (userNameField.getText().toString().trim().equalsIgnoreCase("")) { userNameField.setError("Oops! you need to fill this field"); View view = getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } return false; } return false; } }); //forgot password action forgot_password.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { LayoutInflater li = LayoutInflater.from(MainActivity.this); View promptsView = li.inflate(R.layout.email_prompt, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this); // set prompts.xml to alertdialog builder alertDialogBuilder.setView(promptsView); final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput); // set dialog message alertDialogBuilder.setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to result // edit text //result.setText(userInput.getText()); if (!userInput.getText().toString().equals("")) { ParseUser.requestPasswordResetInBackground(userInput.getText().toString(), new RequestPasswordResetCallback() { public void done(ParseException e) { if (e == null) { Toast.makeText(MainActivity.this, "An email was successfully " + "sent with reset instructions.", Toast.LENGTH_LONG).show(); } else { Toast.makeText(MainActivity.this, "Something went wrong.", Toast.LENGTH_LONG).show(); // Something went wrong. Look at the ParseException to see what's up. } } }); } else Toast.makeText(getApplicationContext(), "sorry you must enter your mail", Toast.LENGTH_SHORT).show(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } } ); registerNowButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(getBaseContext(), LoginActivity.class); startActivity(intent); } } ); signButton.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { usernametxt = userNameField.getText().toString(); passwordtxt = passwordField.getText().toString(); if (!usernametxt.equals(settings.getString("userName", "")) || !passwordtxt.equals(settings.getString("password", ""))) { open(getCurrentFocus()); } else { // Retrieve the text entered from the EditText progressDialog.setMessage("please wait..."); progressDialog.show(); connect(); } } } ); }
From source file:com.ideabytes.dgsms.ca.HomeActivity.java
/** * Show alert to handle apk update//from www . ja va 2s . c o m * @param message * @param code */ private void showAlertOnUpdate(final String message, final int code) { android.app.AlertDialog.Builder builder; builder = new android.app.AlertDialog.Builder(HomeActivity.this); builder.setTitle(Utils.getResString(getApplicationContext(), R.string.Dialog_Alert_Title)); builder.setMessage(message); builder.setCancelable(false); //when 404 show only one button,else two buttons means no force update if (code != 404) { builder.setPositiveButton(Utils.getResString(getApplicationContext(), R.string.btn_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MyAppData.getInstance().setApkUpdated(false); dialog.cancel(); } }); } builder.setNegativeButton(Utils.getResString(getApplicationContext(), R.string.btn_update), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = ""; if (NetworkUtil.getConnectivityStatus(getApplicationContext()) != 0) { url = "https://play.google.com/store/apps/details?id=com.ideabytes.dgsms.landstar"; if (APP_NAME.equalsIgnoreCase("DGMOBI_US_GENERIC")) { url = "https://play.google.com/store/apps/details?id=com.ideabytes.dgsms.generic"; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); MyAppData.getInstance().setApkUpdated(false); dialog.cancel(); } else { //show alert to user to connect network AlertDialog alertDialog = new AlertDialog(HomeActivity.this); alertDialog.showDialg(Utils.getResString(R.string.alert_msg_conn_nw)); } } }); android.app.AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:com.umeng.message.example.MainActivity.java
/** * /*from w w w. ja va2s . c om*/ * @param view */ public void upload(View view) { List<Map<String, Object>> all = pushDao.getAll(); if (all.size() == 0) { Toast.makeText(this, "?", Toast.LENGTH_SHORT).show(); return; } // ?? final android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this); builder.setTitle("Upload"); builder.setMessage(""); builder.setCancelable(false); builder.setNegativeButton("", null); // final Button btn = (Button) view; btn.setText("uploading ..."); btn.setClickable(false); RequestParams params = new RequestParams(); params.put("act", "upload_push_msg"); params.put("data", gson.toJson(all)); Log.e("jsondata", gson.toJson(all)); new AsyncHttpClient().post("http://cms.orenda.com.cn:29055/upload_data", params, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); String hasErrors = getString(response, "hasErrors"); if ("false".equals(hasErrors)) { builder.setMessage("?"); pushDao.clear(); } else { String msg = getString(response, "message"); Log.e("upload.hasError=true", msg); builder.setMessage(msg); } btn.setText("UPLOAD"); btn.setClickable(true); builder.show(); } @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { super.onFailure(statusCode, headers, responseString, throwable); Log.e("onFailure1", String.valueOf(responseString) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e("onFailure2", String.valueOf(errorResponse) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e("onFailure3", String.valueOf(errorResponse) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } }); }
From source file:com.patil.geobells.lite.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dataManager = new GeobellsDataManager(this); preferenceManager = new GeobellsPreferenceManager(this); if (new GeobellsPreferenceManager(this).isFirstTime()) { if (!Config.IS_LITE_VERSION) { if (new ConnectivityChecker(this).isOnline()) { licenseHandler = new Handler(); licenseCheckerCallback = new MyLicenseCheckerCallback(); String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); licenseChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(Constants.SALT, getPackageName(), deviceId)), Constants.BASE64_PUBLIC_KEY); doCheck();// ww w. jav a 2 s . c o m } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.dialog_title_license_connection)); builder.setCancelable(false); builder.setMessage(getString(R.string.dialog_message_license_connection)); builder.setPositiveButton(getString(R.string.dialog_button_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }); builder.create().show(); } } } if (isAppInstalled("com.patil.geobells")) { if (Config.IS_LITE_VERSION) { AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(getString(R.string.dialog_title_uninstall_lite)) .setMessage(getString(R.string.dialog_message_uninstall_lite)); builder.create().show(); } else { if (isAppInstalled("com.patil.geobells.lite")) { AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(getString(R.string.dialog_title_uninstall_pro)) .setMessage(getString(R.string.dialog_message_uninstall_pro)).setPositiveButton( getString(R.string.dialog_button_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); builder.create().show(); } } } //Get a Tracker (should auto-report) ((GeobellsApplication) getApplication()).getTracker(GeobellsApplication.TrackerName.APP_TRACKER); checkGooglePlayServicesEnabled(); if (!isLocationServiceRunning()) { Intent serviceIntent = new Intent(this, LocationService.class); stopService(serviceIntent); serviceIntent.putExtra(Constants.EXTRA_ACTIVITY, Constants.ACTIVITY_UNKNOWN); startService(serviceIntent); } if (!isActivityServiceRunning()) { Intent serviceIntent = new Intent(this, ActivityRecognitionService.class); stopService(serviceIntent); startService(serviceIntent); } mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager() .findFragmentById(R.id.navigation_drawer); // Hide the upgrade button if it's the pro version if (!Config.IS_LITE_VERSION) { Button upgradeButton = (Button) mNavigationDrawerFragment.getView() .findViewById(R.id.navigation_upgrade); View upgradeLine = (View) mNavigationDrawerFragment.getView() .findViewById(R.id.navigation_upgrade_line); upgradeButton.setVisibility(View.GONE); upgradeLine.setVisibility(View.GONE); } title = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); }