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.galois.qrstream.lib.DecodeThread.java
private Intent buildIntent(Job message) throws IOException { Intent i = new Intent(); i.setAction(Intent.ACTION_SEND);//w ww. j a v a2 s. c o m i.addCategory(Intent.CATEGORY_DEFAULT); String mimeType = message.getMimeType(); i.setType(mimeType); if (mimeType.equals("text/plain")) { String msg = new String(message.getData()); i.putExtra(Intent.EXTRA_TEXT, msg); } else { // content that is not text uses the filesystem to store the data // (when sharing with a new local app) File dataLoc = storeData(message); if (mimeType.startsWith("image/")) { String path = Images.Media.insertImage(context.getContentResolver(), dataLoc.getPath(), message.getTitle(), null); Uri imageUri = Uri.parse(path); i.putExtra(Intent.EXTRA_STREAM, imageUri); // we can delete the temporary location in this case, since the file has been saved // to the media store. // In the other cases, the receiver has to handle the content of the temp file before // it can be deleted -- but we will never know if/when that happens. dataLoc.delete(); } else if (mimeType.equals(Constants.MIME_TYPE_TEXT_NOTE)) { String json = new String(message.getData()); try { JSONObject note = new JSONObject(json); i.putExtra(Intent.EXTRA_TEXT, note.getString(Intent.EXTRA_TEXT)); i.putExtra(Intent.EXTRA_SUBJECT, note.getString(Intent.EXTRA_SUBJECT)); i.setType("text/plain"); } catch (JSONException e) { e.printStackTrace(); } } else { i.putExtra(Intent.EXTRA_STREAM, dataLoc.toURI()); } } return i; }
From source file:me.zuichu.ijkplayer.ui.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent();// www . ja v a 2 s . c o m String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown scheme\n"); finish(); return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:com.ideateam.plugin.Emailer.java
private void SendEmail(String email, String subject, String text, String attachFile) { String attachPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/UAR2015/" + attachFile; File file = new File(attachPath); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(text)); this.cordova.getActivity().startActivity(Intent.createChooser(intent, "Send email...")); }
From source file:com.danxx.brisktvlauncher.ui.FullScreenVideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent();/* ww w . j a v a2 s .co m*/ String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown ccheme\n"); finish(); return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); // mMediaController = new AndroidMediaController(this, false); // mMediaController.setSupportActionBar(actionBar); customMediaController = new CustomMediaController(this, false); customMediaController.setSupportActionBar(actionBar); actionBar.setDisplayHomeAsUpEnabled(true); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(customMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:com.example.android.popmovies.MainActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mMovieAdapter = new ImageAdapter(getActivity()); View rootView = inflater.inflate(R.layout.fragment_main, container, false); GridView gridView = (GridView) rootView.findViewById(R.id.gridview_movie); gridView.setAdapter(mMovieAdapter);/*from w w w .j a v a 2 s. co m*/ gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { Movie movie = mMovies.getMovie(position); Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, movie.toString()); // Send formatted description intent.putExtra(Intent.EXTRA_STREAM, movie.getPosterUri()); // Send poster URL w/prefix startActivity(intent); } }); return rootView; }
From source file:com.activiti.android.app.fragments.task.TaskFormFragment.java
@Subscribe public void onDownloadTransferEvent(DownloadTransferEvent event) { if (event.hasException) { Snackbar.make(getActivity().findViewById(R.id.left_panel), event.exception.getMessage(), Snackbar.LENGTH_SHORT).show(); return;/* ww w.j av a 2 s .c o m*/ } hideWaiting(); try { switch (event.mode) { case ContentTransferSyncAdapter.MODE_SHARE: Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName()); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(event.data)); sendIntent.setType(event.mimetype); getActivity().startActivity( Intent.createChooser(sendIntent, getResources().getText(R.string.action_send_file))); break; case ContentTransferSyncAdapter.MODE_OPEN_IN: Intent viewIntent = new Intent(Intent.ACTION_VIEW); viewIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName()); viewIntent.setDataAndType(Uri.fromFile(event.data), event.mimetype); startActivity(viewIntent); break; } } catch (ActivityNotFoundException e) { Snackbar.make(getActivity().findViewById(R.id.left_panel), R.string.file_editor_error_open, Snackbar.LENGTH_SHORT).show(); } }
From source file:com.microsoft.filediscovery.FileItemActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); mApplication = (DiscoveryAPIApplication) getApplication(); setContentView(R.layout.activity_file_display); Bundle bundle = getIntent().getExtras(); Uri imageUri = (Uri) bundle.get(Intent.EXTRA_STREAM); try {//from w w w .j a va 2 s .c om if (imageUri != null) { bundle = new ShareTask(this, imageUri, getIntent()).execute().get().getExtras(); } DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); mResizer = new BitmapResizer(displayMetrics); String data = bundle.getString(Constants.DATA); if (data != null) { JSONObject payload; payload = new JSONObject(data); mFileSaveItem = new FileItem(); mResourceId = payload.getString(Constants.RESOURCEID); mEndPoint = payload.getString(Constants.ENDPOINT); mFileSaveItem.setResourceId(mResourceId); mFileSaveItem.setEndpoint(mEndPoint); ShowImageToShare(Uri.parse(payload.getString("uri"))); } } catch (Exception e) { Log.e("Asset", e.getMessage()); } }
From source file:com.example.yf.ijkplayerdemo.activities.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent();//from w ww . ja va2 s . c om String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown ccheme\n"); finish(); return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:com.android.cts.verifier.managedprovisioning.NfcTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.byod_nfc_test_activity); mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mUserMangaer = (UserManager) getSystemService(Context.USER_SERVICE); mDisallowByPolicy = getIntent().getBooleanExtra(EXTRA_DISALLOW_BY_POLICY, false); if (mDisallowByPolicy) { mDevicePolicyManager.addUserRestriction(mAdminReceiverComponent, UserManager.DISALLOW_OUTGOING_BEAM); }/*from w ww.j a va 2s . c om*/ final Uri uri = createUriForImage(SAMPLE_IMAGE_FILENAME, SAMPLE_IMAGE_CONTENT); Uri[] uris = new Uri[] { uri }; mNfcAdapter = NfcAdapter.getDefaultAdapter(this); mNfcAdapter.setBeamPushUris(uris, this); findViewById(R.id.manual_beam_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mNfcAdapter.invokeBeam(NfcTestActivity.this); } }); findViewById(R.id.intent_share_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Specify the package name of NfcBeamActivity so that the tester don't need to // select the activity manually. shareIntent.setClassName(NFC_BEAM_PACKAGE, NFC_BEAM_ACTIVITY); try { startActivity(shareIntent); } catch (ActivityNotFoundException e) { Toast.makeText(NfcTestActivity.this, R.string.provisioning_byod_cannot_resolve_beam_activity, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Nfc beam activity not found", e); } } }); }