List of usage examples for android.content Intent EXTRA_STREAM
String EXTRA_STREAM
To view the source code for android.content Intent EXTRA_STREAM.
Click Source Link
From source file:com.googlecode.eyesfree.brailleback.WebViewDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(getIntent().getIntExtra(Intent.EXTRA_TITLE, R.string.pref_os_license_title)); setContentView(R.layout.activity_licenses); WebView webView = (WebView) findViewById(R.id.content); webView.loadUrl(getIntent().getStringExtra(Intent.EXTRA_STREAM)); }
From source file:io.github.protino.codewatch.utils.FileProviderUtils.java
public static void shareBitmap(Context context, Bitmap bitmap) throws IOException { final String imageName = "/" + String.valueOf(System.currentTimeMillis()); //First save the bitmap to cache directory File directory = new File(context.getCacheDir(), CACHE_DIR_NAME); if (!directory.mkdirs()) { //delete all data under this folder deleteRecursive(directory);// w w w. j av a2s . co m //recreate the directory directory = new File(context.getCacheDir(), CACHE_DIR_NAME); directory.mkdirs(); } FileOutputStream stream = new FileOutputStream(directory + imageName + IMAGE_EXTENSION); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); stream.flush(); stream.close(); //Now create uri through FileProvider File newFile = new File(directory, imageName + IMAGE_EXTENSION); Uri uri = FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, newFile); if (uri != null) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(uri, context.getContentResolver().getType(uri)); intent.setType("image/png"); intent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_app))); } }
From source file:com.example.android.supportv4.content.FileProviderExample.java
public void onShareFileClick(View view) { // Save a thumbnail to file final File thumbsDir = new File(getFilesDir(), "thumbs"); thumbsDir.mkdirs();/*from w w w . ja v a 2 s . c om*/ final File file = new File(thumbsDir, "private.png"); saveThumbnail(view, file); // Now share that private file using FileProvider final Uri uri = FileProvider.getUriForFile(this, AUTHORITY, file); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/png"); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(intent); }
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
public static void buildAndSend(final Context context) { if (!SU.available()) { Toast.makeText(context, R.string.toast_needs_root, Toast.LENGTH_SHORT).show(); return;/*from w ww.j a v a 2 s .co m*/ } Toast.makeText(context, R.string.building_toast, Toast.LENGTH_LONG).show(); final BugReportBuilder brb = new BugReportBuilder(context); new AsyncTask<Void, Void, Uri>() { @Override protected Uri doInBackground(Void... params) { return brb.build(); } @Override protected void onPostExecute(Uri result) { final ArrayList<Parcelable> uris = new ArrayList<Parcelable>(); uris.add(result); final Intent target = new Intent(Intent.ACTION_SEND_MULTIPLE); target.setType("text/plain"); target.putExtra(Intent.EXTRA_SUBJECT, "[REPORT][AppOpsXposed " + Util.getAoxVersion(context) + "] " + Build.FINGERPRINT); target.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); //target.putExtra(Intent.EXTRA_STREAM, result); target.putExtra(Intent.EXTRA_TEXT, "!!! BUG REPORTS WITHOUT ADDITIONAL INFO WILL BE IGNORED !!!"); //target.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); final Intent intent = Intent.createChooser(target, null); //intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); } }.execute(); }
From source file:ca.rmen.android.networkmonitor.app.savetostorage.SaveToStorageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "onCreate: bundle=" + savedInstanceState); if (savedInstanceState == null) { Parcelable extra = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); if (extra == null || !(extra instanceof Uri)) { SaveToStorage.displayErrorToast(this); return; }//from w w w . ja va2 s . co m Uri sourceFileUri = (Uri) extra; if (!"file".equals(sourceFileUri.getScheme())) { SaveToStorage.displayErrorToast(this); return; } if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { SaveToStorage.displayErrorToast(this); return; } File initialFolder = NetMonPreferences.getInstance(this).getExportFolder(); DialogFragmentFactory.showFileChooserDialog(this, initialFolder, true, ACTION_SAVE_TO_STORAGE); } }
From source file:com.btmura.android.reddit.app.MenuHelper.java
public static void shareImageUrl(Context context, String url) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url)); Contexts.startActivity(context, intent); }
From source file:com.hippo.nimingban.ui.TypeSendActivity.java
private Bundle createArgs() { Bundle bundle = new Bundle(); Intent intent = getIntent();//from w w w. jav a 2s .co m if (intent != null) { bundle.putString(TypeSendFragment.KEY_ACTION, intent.getAction()); bundle.putString(TypeSendFragment.KEY_TYPE, intent.getType()); bundle.putInt(TypeSendFragment.KEY_SITE, intent.getIntExtra(KEY_SITE, -1)); bundle.putString(TypeSendFragment.KEY_ID, intent.getStringExtra(KEY_ID)); bundle.putString(TypeSendFragment.KEY_TEXT, intent.getStringExtra(KEY_TEXT)); bundle.putString(TypeSendFragment.KEY_EXTRA_TEXT, intent.getStringExtra(Intent.EXTRA_TEXT)); bundle.putParcelable(TypeSendFragment.KEY_EXTRA_STREAM, intent.getParcelableExtra(Intent.EXTRA_STREAM)); } return bundle; }
From source file:edu.stanford.mobisocial.dungbeetle.obj.action.ExportPhotoAction.java
@Override public void onAct(Context context, DbEntryHandler objType, DbObj obj) { byte[] raw = obj.getRaw(); if (raw == null) { String b64Bytes = obj.getJson().optString(PictureObj.DATA); raw = FastBase64.decode(b64Bytes); }/*from ww w. j a v a 2 s.com*/ OutputStream outStream = null; File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp_share.png"); try { outStream = new FileOutputStream(file); BitmapManager mgr = new BitmapManager(1); Bitmap bitmap = mgr.getBitmap(raw.hashCode(), raw); bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream); outStream.flush(); outStream.close(); bitmap.recycle(); bitmap = null; System.gc(); Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("image/png"); Log.w("ResharePhotoAction", Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp_share.png"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); context.startActivity(Intent.createChooser(intent, "Export image to")); } catch (Exception e) { e.printStackTrace(); } }
From source file:ee.ria.DigiDoc.activity.OpenExternalFileActivity.java
private void handleIntentAction() { Intent intent = getIntent();/*from ww w .j a v a2 s .co m*/ ContainerFacade container = null; Timber.d("Handling action: %s ", intent.getAction()); switch (intent.getAction()) { case Intent.ACTION_VIEW: try { container = createContainer(intent.getData()); } catch (Exception e) { Timber.e(e, "Error creating container from uri %s", intent.getData().toString()); } break; case Intent.ACTION_SEND: Uri sendUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (sendUri != null) { container = createContainer(sendUri); } break; case Intent.ACTION_SEND_MULTIPLE: ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { container = createContainer(uris); } break; } if (container != null) { createContainerDetailsFragment(container); } else { createErrorFragment(); } }
From source file:org.alfresco.mobile.android.platform.intent.BaseActionUtils.java
/** * Allow user to share a file with other applications. * /*from w ww .ja va 2 s. c o m*/ * @param fr * @param contentFile */ public static void actionShareContent(Fragment fr, File contentFile) { try { Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_SUBJECT, contentFile.getName()); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(contentFile)); i.setType(MimeTypeManager.getInstance(fr.getActivity()).getMIMEType(contentFile.getName())); fr.startActivity(Intent.createChooser(i, fr.getActivity().getText(R.string.share_content))); } catch (ActivityNotFoundException e) { AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(), R.string.error_unable_share_content); } }