List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.android.gallery3d.app.PhotoPage.java
private void launchSimpleEditor() { MediaItem current = mModel.getMediaItem(0); if (current == null || (current.getSupportedOperations() & MediaObject.SUPPORT_EDIT) == 0) { return;/*w w w . j av a 2 s . co m*/ } Intent intent = new Intent(ACTION_SIMPLE_EDIT); intent.setDataAndType(current.getContentUri(), current.getMimeType()) .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY) .size() == 0) { intent.setAction(Intent.ACTION_EDIT); } intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen()); ((Activity) mActivity).startActivityForResult(Intent.createChooser(intent, null), REQUEST_EDIT); overrideTransitionToEditor(); }
From source file:com.edible.ocr.CaptureActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); switch (item.getItemId()) { case OPTIONS_COPY_RECOGNIZED_TEXT_ID: clipboardManager.setText(ocrResultView.getText()); if (clipboardManager.hasText()) { Toast toast = Toast.makeText(this, "Text copied.", Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show();//from w w w . j ava 2 s. c om } return true; case OPTIONS_SHARE_RECOGNIZED_TEXT_ID: Intent shareRecognizedTextIntent = new Intent(android.content.Intent.ACTION_SEND); shareRecognizedTextIntent.setType("text/plain"); shareRecognizedTextIntent.putExtra(android.content.Intent.EXTRA_TEXT, ocrResultView.getText()); startActivity(Intent.createChooser(shareRecognizedTextIntent, "Share via")); return true; case OPTIONS_COPY_TRANSLATED_TEXT_ID: clipboardManager.setText(translationView.getText()); if (clipboardManager.hasText()) { Toast toast = Toast.makeText(this, "Text copied.", Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); } return true; case OPTIONS_SHARE_TRANSLATED_TEXT_ID: Intent shareTranslatedTextIntent = new Intent(android.content.Intent.ACTION_SEND); shareTranslatedTextIntent.setType("text/plain"); shareTranslatedTextIntent.putExtra(android.content.Intent.EXTRA_TEXT, translationView.getText()); startActivity(Intent.createChooser(shareTranslatedTextIntent, "Share via")); return true; default: return super.onContextItemSelected(item); } }
From source file:com.kncwallet.wallet.ui.WalletActivity.java
private void mailPrivateKeys(@Nonnull final File file) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_keys_dialog_mail_subject)); intent.putExtra(Intent.EXTRA_TEXT,/* w ww . ja va2 s. c om*/ getString(R.string.export_keys_dialog_mail_text) + "\n\n" + String.format(Constants.WEBMARKET_APP_URL, getPackageName()) + "\n\n" + Constants.SOURCE_URL + '\n'); intent.setType("x-bitcoin/private-keys"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); startActivity(Intent.createChooser(intent, getString(R.string.export_keys_dialog_mail_intent_chooser))); log.info("invoked archive private keys chooser"); }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
public void emailReport() { if (CustomLogger.isMainActivityReporting()) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "lgallard+qbcontroller@gmail.com" }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "qBittorrentController report"); // Include report emailIntent.putExtra(Intent.EXTRA_TEXT, CustomLogger.getReport()); // Delete report CustomLogger.setMainActivityReporting(false); CustomLogger.deleteMainReport(); CustomLogger.deleteNotifierReport(); // Launch email chooser startActivity(Intent.createChooser(emailIntent, "Send qBittorrent report...")); // Reporting - Finish report CustomLogger.setMainActivityReporting(false); }/*from w ww .ja v a 2 s . c o m*/ }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from ww w . ja va 2 s . c o m*/ AlertDialog.Builder builder; switch (id) { case DIALOG_SHORT_WAIT: { ProgressDialog working_dialog = new ProgressDialog(this); working_dialog.setMessage(getResources().getString(R.string.wait_a_moment)); working_dialog.setIndeterminate(true); working_dialog.setCancelable(false); dialog = working_dialog; break; } case DIALOG_CHOOSE_UPLOAD_SOURCE: { String[] items = null; String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps), getString(R.string.actionbar_failed_instant_upload) }; String[] commonItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; if (InstantUploadActivity.IS_ENABLED) items = allTheItems; else items = commonItems; builder = new AlertDialog.Builder(this); builder.setTitle(R.string.actionbar_upload); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { // if (!mDualPane) { Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, FileDisplayActivity.this.getAccount()); startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // } else { // TODO create and handle new fragment // LocalFileListFragment // } } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } else if (item == 2 && InstantUploadActivity.IS_ENABLED) { Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class); action.putExtra(FileUploader.KEY_ACCOUNT, FileDisplayActivity.this.getAccount()); startActivity(action); } } }); dialog = builder.create(); break; } case DIALOG_SSL_VALIDATOR: { dialog = SslValidatorDialog.newInstance(this, mLastSslUntrustedServerResult, this); break; } case DIALOG_CERT_NOT_SAVED: { builder = new AlertDialog.Builder(this); builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved)); builder.setCancelable(false); builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }; }); dialog = builder.create(); break; } default: dialog = null; } return dialog; }
From source file:sjizl.com.ChatActivity.java
public void openGallery(int req_code) { // Intent intent2 = new Intent(); // intent2.setType("image/*"); // intent2.setAction(Intent.ACTION_GET_CONTENT); // startActivityForResult(Intent.createChooser(intent2,"Select file to upload "), req_code); // Use the GET_CONTENT intent from the utility class Intent target = FileUtils.createGetContentIntent(); Intent intent = Intent.createChooser(target, getResources().getText(R.string.app_name)); try {/*from w ww. j ava 2 s .c om*/ startActivityForResult(intent, req_code); } catch (ActivityNotFoundException e) { // The reason for the existence of aFileChooser } }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
public void pickImage() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)), SELECT_PICTURE); }
From source file:com.androzic.MapFragment.java
@Override public boolean onMenuItemSelected(MenuBuilder builder, MenuItem item) { switch (item.getItemId()) { case R.id.action_information: { FragmentManager manager = getFragmentManager(); LocationInfo dialog = new LocationInfo(application.getMapCenter()); dialog.show(manager, "dialog"); return true; }/*from www . j a va 2 s . co m*/ case R.id.action_share: { Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, R.string.currentloc); double[] loc = application.getMapCenter(); String spos = StringFormatter.coordinates(" ", loc[0], loc[1]); i.putExtra(Intent.EXTRA_TEXT, spos); startActivity(Intent.createChooser(i, getString(R.string.menu_share))); return true; } case R.id.action_view_elsewhere: { double[] sloc = application.getMapCenter(); String geoUri = "geo:" + Double.toString(sloc[0]) + "," + Double.toString(sloc[1]); Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoUri)); startActivity(intent); return true; } case R.id.action_copy_location: { double[] cloc = application.getMapCenter(); String cpos = StringFormatter.coordinates(" ", cloc[0], cloc[1]); Clipboard.copy(getActivity(), cpos); return true; } case R.id.action_paste_location: { String text = Clipboard.paste(getActivity()); try { double c[] = CoordinateParser.parse(text); if (!Double.isNaN(c[0]) && !Double.isNaN(c[1])) { boolean mapChanged = application.setMapCenter(c[0], c[1], true, true, false); if (mapChanged) map.updateMapInfo(); map.updateMapCenter(); following = false; map.setFollowing(false); } } catch (IllegalArgumentException e) { } return true; } case R.id.action_add_to_route: { Waypoint wpt = application.getWaypoint(waypointSelected); application.routeEditingWaypoints .push(application.editingRoute.addWaypoint(wpt.name, wpt.latitude, wpt.longitude)); refreshMap(); return true; } case R.id.action_navigate: { application.navigationService.setRouteWaypoint(waypointSelected); return true; } case R.id.action_mapobject_navigate: { application.startNavigation(application.getMapObject(mapObjectSelected)); return true; } } return false; }
From source file:cl.gisred.android.InspActivity.java
private void cerrarFormCrear(boolean bSave, View v, int idR) { if (bSave) {/*from w w w .ja v a 2 s. c o m*/ if (!validarForm(v)) { DialogoConfirmacion oDialog = new DialogoConfirmacion(); oDialog.show(getFragmentManager(), "tagAlert"); return; } else { Resources res = getResources(); InputStream in_s = res.openRawResource(R.raw.index); try { View vAction = getLayoutValidate(v); byte[] b = new byte[in_s.available()]; in_s.read(b); String sHtml = new String(b); HtmlUtils oHtml = new HtmlUtils(getApplicationContext(), sHtml); String sValueNumMed = "null"; for (View view : vAction.getTouchables()) { if (view.getClass().getGenericSuperclass().equals(EditText.class)) { EditText oText = (EditText) view; if (!oText.getText().toString().trim().isEmpty()) { String sMapvalue = HtmlUtils.getMapvalue(oText.getId()); String sValorChr = oText.getText().toString(); oHtml.setValueById(sMapvalue, "txt", sValorChr); if (oText.getId() == R.id.txtOT) { sValueNumMed = sValorChr; } if (sMapvalue != null && sMapvalue.contains("txt_trabajo_cant")) { try { double dValue = Double.valueOf(sValorChr); oHtml.sumHH += dValue; } catch (Exception ex) { Log.e("Double Convert", "error: " + ex.getMessage()); } } } } else if (view.getClass().getGenericSuperclass().equals(CheckBox.class)) { CheckBox oCheck = (CheckBox) view; String sCheck = HtmlUtils.getMapvalue(oCheck.getId()); sCheck += oCheck.isChecked() ? "si" : "no"; oHtml.setValueById(sCheck, "chk", ""); } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) { Spinner oSpinner = (Spinner) view; oHtml.setValueById(HtmlUtils.getMapvalue(oSpinner.getId()), "txt", oSpinner.getSelectedItem().toString()); } else if (view.getClass().getGenericSuperclass().equals(RadioButton.class)) { RadioButton oRadioButton = (RadioButton) view; if (oRadioButton.isChecked()) { String sRadio = HtmlUtils .getMapvalue(((RadioGroup) oRadioButton.getParent()).getId()); sRadio += oRadioButton.getText().toString().toLowerCase().replace(" ", ""); oHtml.setValueById(sRadio, "rad", ""); } } else if (view.getClass().getGenericSuperclass().equals(ImageView.class)) { } } //SUMA TOTAL HH oHtml.setValueById("txt_trabajo_cant_tot", "txt", "" + oHtml.sumHH); //VALIDAR FIRMAS if (valImage(vAction, R.id.imgFirmaIns)) oHtml.setValueById("firm_prop", "img", String.format("%s.jpg", R.id.imgFirmaIns)); if (valImage(vAction, R.id.imgFirmaTec)) oHtml.setValueById("firm_tecn", "img", String.format("%s.jpg", R.id.imgFirmaTec)); if (valImage(vAction, R.id.imgPhoto1)) oHtml.setValueById("foto_1", "img", "foto1.jpg"); if (valImage(vAction, R.id.imgPhoto2)) oHtml.setValueById("foto_2", "img", "foto2.jpg"); if (valImage(vAction, R.id.imgPhoto3)) oHtml.setValueById("foto_3", "img", "foto3.jpg"); oHtml.setTitleHtml(sValueNumMed); String sHtmlFinal = oHtml.getHtmlFinal(); //guardar en disco oHtml.createHtml(sHtmlFinal); //VIA CustomTabs /*String url = oHtml.getPathHtml(); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(this, Uri.parse(url));*/ //VIA CHROME scheme if (Util.isPackageExisted("com.android.chrome", this)) { String url = oHtml.getPathHtml(); File f = new File(url); MimeTypeMap mime = MimeTypeMap.getSingleton(); String ext = f.getName().substring(f.getName().lastIndexOf(".") + 1); String type = mime.getMimeTypeFromExtension(ext); Uri uri = Uri.parse("googlechrome://navigate?url=" + url); Intent in = new Intent(Intent.ACTION_VIEW); //in.setDataAndType(uri, "text/html"); in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); in.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //Uri uriExternal = FileProvider.getUriForFile(getApplicationContext(), "cl.gisred.android", f); in.setDataAndType(uri, type); //startActivity(in); startActivity(Intent.createChooser(in, "Escoja Chrome")); } else { Toast.makeText(this, "Debe instalar Chrome, solo preview disponible", Toast.LENGTH_LONG) .show(); Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(oHtml.getPathHtml())); startActivity(myIntent); } } catch (IOException e) { e.printStackTrace(); } } } menuMultipleActions.setVisibility(View.VISIBLE); menuInspeccionActions.setVisibility(View.VISIBLE); fabShowForm.setVisibility(View.GONE); formCrear.dismiss(); }