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.irccloud.android.activity.ShareChooserActivity.java
@Override public void onBufferSelected(int bid) { Intent i = new Intent(this, MainActivity.class); i.putExtra("bid", bid); if (getIntent() != null && getIntent().getData() != null) i.setData(getIntent().getData()); if (getIntent() != null && getIntent().getExtras() != null) { i.putExtras(getIntent());/* www . ja v a2s . co m*/ if (mUri != null) i.putExtra(Intent.EXTRA_STREAM, mUri); } startActivity(i); finish(); }
From source file:info.papdt.blacklight.ui.statuses.NewPostActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mLayout = R.layout.post_status;/* w ww . j av a 2 s . c om*/ super.onCreate(savedInstanceState); mLoginCache = new LoginApiCache(this); mUserCache = new UserApiCache(this); new GetAvatarTask().execute(); // Initialize views mText = Utility.findViewById(this, R.id.post_edit); mCount = Utility.findViewById(this, R.id.post_count); mDrawer = Utility.findViewById(this, R.id.post_drawer); mAvatar = Utility.findViewById(this, R.id.post_avatar); mScroll = Utility.findViewById(this, R.id.post_scroll); mPicsParent = Utility.findViewById(this, R.id.post_pics); mPic = Utility.findViewById(this, R.id.post_pic); mEmoji = Utility.findViewById(this, R.id.post_emoji); mAt = Utility.findViewById(this, R.id.post_at); mTopic = Utility.findViewById(this, R.id.post_topic); mSend = Utility.findViewById(this, R.id.post_send); mCache = getSharedPreferences("post_cache", MODE_PRIVATE); // Bind onClick events Utility.bindOnClick(this, mPic, "pic"); Utility.bindOnClick(this, mEmoji, "emoji"); Utility.bindOnClick(this, mAt, "at"); Utility.bindOnClick(this, mTopic, "topic"); Utility.bindOnClick(this, mSend, "send"); Utility.bindOnClick(this, mAvatar, "avatar"); // Version try { mVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (Exception e) { } // Hints if (Math.random() < 0.42) { // Make this a matter of possibility. mHints = getResources().getStringArray(R.array.splashes); mText.setHint(mHints[new Random().nextInt(mHints.length)]); } // Fragments mEmoticonFragment = new EmoticonFragment(); mColorPickerFragment = new ColorPickerFragment(); getFragmentManager().beginTransaction().replace(R.id.post_emoticons, mEmoticonFragment).commit(); // Filter try { TypedArray array = getTheme().obtainStyledAttributes(R.styleable.BlackLight); mFilter = array.getColor(R.styleable.BlackLight_NewPostImgFilter, 0); mForeground = array.getColor(R.styleable.BlackLight_NewPostForeground, 0); array.recycle(); } catch (Exception e) { mFilter = 0; } // Listeners mEmoticonFragment.setEmoticonListener(new EmoticonFragment.EmoticonListener() { @Override public void onEmoticonSelected(String name) { mText.getText().insert(mText.getSelectionStart(), name); mDrawer.closeDrawer(Gravity.RIGHT); } }); mColorPickerFragment.setOnColorSelectedListener(new ColorPickerFragment.OnColorSelectedListener() { @Override public void onSelected(String hex) { int sel = mText.getSelectionStart(); mText.getText().insert(sel, "[" + hex + " [d"); mText.setSelection(sel + 9); mDrawer.closeDrawer(Gravity.RIGHT); } }); mText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (needCache()) mCache.edit().putString(DRAFT, s.toString()).apply(); } @Override public void afterTextChanged(Editable s) { // How many Chinese characters (1 Chinses character = 2 English characters) try { int length = Utility.lengthOfString(s.toString()); if (DEBUG) { Log.d(TAG, "Text length = " + length); } if (length <= 140 && !s.toString().contains("\n")) { mCount.setTextColor(mForeground); mCount.setText(String.valueOf(140 - length)); mIsLong = false; } else if (!(NewPostActivity.this instanceof RepostActivity) && !(NewPostActivity.this instanceof CommentOnActivity) && !(NewPostActivity.this instanceof ReplyToActivity)) { mCount.setText(getResources().getString(R.string.long_post)); mIsLong = true; } else { mCount.setTextColor(getResources().getColor(android.R.color.holo_red_light)); mCount.setText(String.valueOf(140 - length)); mIsLong = false; } } catch (Exception e) { } if (mEmoji != null) { if (mIsLong) { getFragmentManager().beginTransaction().replace(R.id.post_emoticons, mColorPickerFragment) .commit(); mEmoji.setImageResource(R.drawable.ic_mode_edit_black_36dp); } else { getFragmentManager().beginTransaction().replace(R.id.post_emoticons, mEmoticonFragment) .commit(); mEmoji.setImageResource(R.drawable.ic_emoji); } } } }); getWindow().getDecorView().getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mText.requestFocus(); mText.requestFocusFromTouch(); // Draft if (needCache()) mText.setText(mCache.getString(DRAFT, "")); // Must be removed getWindow().getDecorView().getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); // Imgs for (int i = 0; i < 9; i++) { mPics[i] = (ImageView) mPicsParent.getChildAt(i); mPics[i].setOnLongClickListener(this); mPics[i].setOnClickListener(this); } // Handle share intent Intent i = getIntent(); if (i != null && i.getType() != null) { if (i.getType().contains("text/plain")) { mText.setText(i.getStringExtra(Intent.EXTRA_TEXT)); } else if (i.getType().contains("image/")) { Uri uri = (Uri) i.getParcelableExtra(Intent.EXTRA_STREAM); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); addPicture(bitmap, null); } catch (IOException e) { if (DEBUG) { Log.d(TAG, Log.getStackTraceString(e)); } } } } }
From source file:io.nuclei.cyto.share.PackageTargetManager.java
/** * Set default intent data//from w w w .ja va 2 s .com */ protected void onSetDefault(Context context, String packageName, String authority, Intent intent, String text) { intent.putExtra(Intent.EXTRA_TEXT, text); if (!TextUtils.isEmpty(mSubject)) intent.putExtra(Intent.EXTRA_SUBJECT, mSubject); if (mUri != null || mFile != null) { Uri uri = mUri; String type = "*/*"; if (mFile != null) { uri = FileProvider.getUriForFile(context, authority, mFile); final int lastDot = mFile.getName().lastIndexOf('.'); if (lastDot >= 0) { String extension = mFile.getName().substring(lastDot + 1); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mimeType != null) type = mimeType; } } intent.setDataAndType(intent.getData(), type); intent.putExtra(Intent.EXTRA_STREAM, uri); if (packageName != null) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); } } else { intent.setType("text/plain"); } if (!TextUtils.isEmpty(mEmail)) { intent.putExtra(Intent.EXTRA_EMAIL, new String[] { mEmail }); intent.setData(Uri.parse("mailto:")); } }
From source file:info.guardianproject.pixelknot.PixelKnotActivity.java
@Override public void share() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pixel_knot.out_file)); intent.setType("image/jpeg"); startActivity(Intent.createChooser(intent, getString(R.string.embed_success))); }
From source file:com.google.android.apps.forscience.whistlepunk.review.RunReviewFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mStartLabelId = getArguments().getString(ARG_START_LABEL_ID); mSelectedSensorIndex = getArguments().getInt(ARG_SENSOR_INDEX); }// w w w . j a v a2s .co m if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_SELECTED_SENSOR_INDEX)) { // saved instance state is more recent than args, so it takes precedence. mSelectedSensorIndex = savedInstanceState.getInt(KEY_SELECTED_SENSOR_INDEX); } mShowStatsOverlay = savedInstanceState.getBoolean(KEY_STATS_OVERLAY_VISIBLE, false); } mRunReviewExporter = new RunReviewExporter(getDataController(), new RunReviewExporter.Listener() { @Override public void onExportStarted() { showExportUi(); } @Override public void onExportProgress(int progress) { setExportProgress(progress); } @Override public void onExportEnd(Uri uri) { resetExportUi(); if (uri != null) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("application/octet-stream"); intent.putExtra(Intent.EXTRA_STREAM, uri); getActivity().startActivity( Intent.createChooser(intent, getString(R.string.export_run_chooser_title))); } } @Override public void onExportError(Exception e) { resetExportUi(); if (getActivity() != null) { Snackbar bar = AccessibilityUtils.makeSnackbar(getView(), getString(R.string.export_error), Snackbar.LENGTH_LONG); bar.show(); } } }); setHasOptionsMenu(true); }
From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java
public static boolean actionSendMailWithAttachment(Fragment fr, String subject, String content, Uri attachment, int requestCode) { try {/*w ww . jav a 2 s.co m*/ Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(content)); i.putExtra(Intent.EXTRA_STREAM, attachment); i.setType("text/plain"); if (i.resolveActivity(fr.getActivity().getPackageManager()) == null) { AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(), fr.getString(R.string.feature_disable)); return false; } fr.startActivityForResult(Intent.createChooser(i, fr.getString(R.string.send_email)), requestCode); return true; } catch (Exception e) { AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(), R.string.decryption_failed); Log.d(TAG, Log.getStackTraceString(e)); } return false; }
From source file:com.studyjams.mdvideo.PlayerModule.ExoPlayerV2.PlayerActivityV2.java
/**debug?**/ // @Override/*from w w w .ja va 2 s . c om*/ // public void onClick(View view) { // if (view == retryButton) { // initializePlayer(); // } else if (view.getParent() == debugRootView) { // trackSelectionHelper.showSelectionDialog(this, ((Button) view).getText(), // trackSelector.getCurrentSelections().info, (int) view.getTag()); // } // } // PlaybackControlView.VisibilityListener implementation // // @Override // public void onVisibilityChange(int visibility) { // debugRootView.setVisibility(visibility); // } // Internal methods private void initializePlayer() { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); String intentType = intent.getStringExtra(CONTENT_TYPE_INTENT); if (Intent.ACTION_SEND.equals(action) && type.equals("video/*")) { mContentUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); mContentId = ""; mContentPosition = C.TIME_UNSET; mSubtitleUri = null; } else if (intentType.equals(D.TYPE_VIDEO)) { mContentUri = intent.getData(); mContentId = intent.getStringExtra(CONTENT_ID_EXTRA); mContentPosition = intent.getLongExtra(CONTENT_POSITION_EXTRA, 0); String subtitle = intent.getStringExtra(CONTENT_SUBTITLE_EXTRA); if (!TextUtils.isEmpty(subtitle)) { mSubtitleUri = Uri.parse(subtitle); } else { mSubtitleUri = null; } playerPosition = mContentPosition; } else if (intentType.equals(D.TYPE_SUBTITLE)) { mSubtitleUri = intent.getData(); } if (player == null) { boolean preferExtensionDecoders = intent.getBooleanExtra(PREFER_EXTENSION_DECODERS, false); UUID drmSchemeUuid = intent.hasExtra(DRM_SCHEME_UUID_EXTRA) ? UUID.fromString(intent.getStringExtra(DRM_SCHEME_UUID_EXTRA)) : null; DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null; if (drmSchemeUuid != null) { String drmLicenseUrl = intent.getStringExtra(DRM_LICENSE_URL); String[] keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES); Map<String, String> keyRequestProperties; if (keyRequestPropertiesArray == null || keyRequestPropertiesArray.length < 2) { keyRequestProperties = null; } else { keyRequestProperties = new HashMap<>(); for (int i = 0; i < keyRequestPropertiesArray.length - 1; i += 2) { keyRequestProperties.put(keyRequestPropertiesArray[i], keyRequestPropertiesArray[i + 1]); } } try { drmSessionManager = buildDrmSessionManager(drmSchemeUuid, drmLicenseUrl, keyRequestProperties); } catch (UnsupportedDrmException e) { int errorStringId = Util.SDK_INT < 18 ? R.string.error_drm_not_supported : (e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME ? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown); showToast(errorStringId); return; } } eventLogger = new EventLogger(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory( BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory); trackSelector.addListener(this); trackSelector.addListener(eventLogger); trackSelectionHelper = new TrackSelectionHelper(trackSelector, videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(), drmSessionManager, preferExtensionDecoders); player.addListener(this); player.addListener(eventLogger); player.setAudioDebugListener(eventLogger); player.setVideoDebugListener(eventLogger); player.setId3Output(eventLogger); simpleExoPlayerView.setPlayer(player); //?mediaController controller.setPlayer(player); controller.setTitle(mContentUri.getLastPathSegment()); // if (isTimelineStatic) { if (playerPosition == C.TIME_UNSET) { player.seekToDefaultPosition(playerWindow); } else { player.seekTo(playerWindow, playerPosition); } // } player.setPlayWhenReady(shouldAutoPlay); /**? debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.start();**/ playerNeedsSource = true; } if (playerNeedsSource) { // String action = intent.getAction(); Uri[] uris; String[] extensions; if (ACTION_VIEW.equals(action)) { // uris = new Uri[]{intent.getData()}; uris = new Uri[] { mContentUri }; extensions = new String[] { intent.getStringExtra(EXTENSION_EXTRA) }; } else if (ACTION_VIEW_LIST.equals(action)) { String[] uriStrings = intent.getStringArrayExtra(URI_LIST_EXTRA); uris = new Uri[uriStrings.length]; for (int i = 0; i < uriStrings.length; i++) { uris[i] = Uri.parse(uriStrings[i]); } extensions = intent.getStringArrayExtra(EXTENSION_LIST_EXTRA); if (extensions == null) { extensions = new String[uriStrings.length]; } } else { showToast(getString(R.string.unexpected_intent_action, action)); return; } if (Util.maybeRequestReadExternalStoragePermission(this, uris)) { // The player will be reinitialized if the permission is granted. return; } MediaSource[] mediaSources = new MediaSource[uris.length]; for (int i = 0; i < uris.length; i++) { mediaSources[i] = buildMediaSource(uris[i], extensions[i]); } MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0] : new ConcatenatingMediaSource(mediaSources); player.prepare(mediaSource, !isTimelineStatic, !isTimelineStatic); playerNeedsSource = false; // updateButtonVisibilities(); } }
From source file:com.pixby.texo.MainActivity.java
private void runShareIntent(Uri uri) { final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/jpg"); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); String message = getResources().getString(R.string.action_share_photo); startActivity(Intent.createChooser(shareIntent, message)); }
From source file:nl.sogeti.android.gpstracker.actions.Statistics.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean handled = false; Intent intent;//from w w w .j a va 2 s . c om switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); handled = true; break; case MENU_GRAPHTYPE: showDialog(DIALOG_GRAPHTYPE); handled = true; break; case MENU_TRACKLIST: intent = new Intent(this, TrackList.class); intent.putExtra(Tracks._ID, mTrackUri.getLastPathSegment()); startActivityForResult(intent, MENU_TRACKLIST); break; case MENU_SHARE: intent = new Intent(Intent.ACTION_RUN); intent.setDataAndType(mTrackUri, Tracks.CONTENT_ITEM_TYPE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Bitmap bm = mViewFlipper.getDrawingCache(); Uri screenStreamUri = ShareTrack.storeScreenBitmap(bm); intent.putExtra(Intent.EXTRA_STREAM, screenStreamUri); startActivityForResult(Intent.createChooser(intent, getString(R.string.share_track)), MENU_SHARE); handled = true; break; default: handled = super.onOptionsItemSelected(item); } return handled; }