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:de.enlightened.peris.PerisMain.java
final void handleSendMultipleImages(final Intent intent) { final ArrayList<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); /*// ww w .ja v a2 s .c om if (imageUris != null) { // Update UI to reflect multiple images being shared }*/ }
From source file:it.feio.android.omninotes.DetailFragment.java
/** * Performs an action when long-click option is selected * @param attachmentPosition//from www. j av a2 s . co m * @param i item index */ private void performAttachmentAction(int attachmentPosition, int i) { switch (getResources().getStringArray(R.array.attachments_actions_values)[i]) { case "share": Intent shareIntent = new Intent(Intent.ACTION_SEND); Attachment attachment = mAttachmentAdapter.getItem(attachmentPosition); shareIntent.setType(StorageHelper.getMimeType(OmniNotes.getAppContext(), attachment.getUri())); shareIntent.putExtra(Intent.EXTRA_STREAM, attachment.getUri()); if (IntentChecker.isAvailable(OmniNotes.getAppContext(), shareIntent, null)) { startActivity(shareIntent); } else { mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.WARN); } break; case "delete": removeAttachment(attachmentPosition); mAttachmentAdapter.notifyDataSetChanged(); mGridView.autoresize(); break; case "delete all": new MaterialDialog.Builder(mainActivity).title(R.string.delete_all_attachments) .positiveText(R.string.confirm) .onPositive((materialDialog, dialogAction) -> removeAllAttachments()).build().show(); break; case "edit": takeSketch(mAttachmentAdapter.getItem(attachmentPosition)); break; default: Log.w(Constants.TAG, "No action available"); } }
From source file:ca.uwaterloo.magic.goodhikes.MapsActivity.java
public void CaptureMapScreen() { GoogleMap.SnapshotReadyCallback callback = new GoogleMap.SnapshotReadyCallback() { Bitmap bitmap;//from ww w .j a va 2 s.com @Override public void onSnapshotReady(Bitmap snapshot) { // TODO Auto-generated method stub bitmap = snapshot; String path = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "route_screenshot", null); Uri uri_image = Uri.parse(path); // share intent Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_STREAM, uri_image); sendIntent.putExtra(Intent.EXTRA_TEXT, "My Route"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Hey! Check out my route on Goodhikes"); sendIntent.setType("image/*"); startActivity(Intent.createChooser(sendIntent, "Share to...")); } }; mMap.snapshot(callback); }
From source file:com.cypress.cysmart.CommonFragments.ProfileScanningFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. switch (item.getItemId()) { case R.id.log: // DataLogger File file = new File(Environment.getExternalStorageDirectory() + File.separator + "CySmart" + File.separator + Utils.GetDate() + ".txt"); String path = file.getAbsolutePath(); Bundle bundle = new Bundle(); bundle.putString(Constants.DATA_LOGGER_FILE_NAAME, path); bundle.putBoolean(Constants.DATA_LOGGER_FLAG, false); /**//from ww w . j ava 2 s . com * Adding new fragment DataLoggerFragment to the view */ FragmentManager fragmentManager = getFragmentManager(); Fragment currentFragment = fragmentManager.findFragmentById(R.id.container); DataLoggerFragment dataloggerfragment = new DataLoggerFragment().create(currentFragment.getTag()); dataloggerfragment.setArguments(bundle); fragmentManager.beginTransaction().add(R.id.container, dataloggerfragment).addToBackStack(null) .commit(); return true; case R.id.share: // Share HomePageActivity.containerView.invalidate(); View v1 = getActivity().getWindow().getDecorView().getRootView(); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); String temporaryPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "CySmart" + File.separator + "file.jpg"; File filetoshare = new File(temporaryPath); if (filetoshare.exists()) { filetoshare.delete(); } try { filetoshare.createNewFile(); Utils.screenShotMethod(v1); Logger.i("temporaryPath>" + temporaryPath); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(temporaryPath))); shareIntent.setType("image/jpg"); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); } catch (IOException e) { e.printStackTrace(); } return true; case R.id.clearcache: showWarningMessage(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.if3games.chessonline.DroidFish.java
/** * Return PGN/FEN data or filename from the Intent. Both can not be non-null. * @return Pair of PGN/FEN data and filename. *//*from w w w.j a v a 2s .c o m*/ private final Pair<String, String> getPgnOrFenIntent() { String pgnOrFen = null; String filename = null; try { Intent intent = getIntent(); Uri data = intent.getData(); if (data == null) { Bundle b = intent.getExtras(); if (b != null) { Object strm = b.get(Intent.EXTRA_STREAM); if (strm instanceof Uri) { data = (Uri) strm; if ("file".equals(data.getScheme())) { filename = data.getEncodedPath(); if (filename != null) filename = Uri.decode(filename); } } } } if (data == null) { if ((Intent.ACTION_SEND.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())) && ("application/x-chess-pgn".equals(intent.getType()) || "application/x-chess-fen".equals(intent.getType()))) pgnOrFen = intent.getStringExtra(Intent.EXTRA_TEXT); } else { String scheme = intent.getScheme(); if ("file".equals(scheme)) { filename = data.getEncodedPath(); if (filename != null) filename = Uri.decode(filename); } if ((filename == null) && ("content".equals(scheme) || "file".equals(scheme))) { ContentResolver resolver = getContentResolver(); InputStream in = resolver.openInputStream(intent.getData()); StringBuilder sb = new StringBuilder(); while (true) { byte[] buffer = new byte[16384]; int len = in.read(buffer); if (len <= 0) break; sb.append(new String(buffer, 0, len)); } pgnOrFen = sb.toString(); } } } catch (IOException e) { Toast.makeText(getApplicationContext(), R.string.failed_to_read_pgn_data, Toast.LENGTH_SHORT).show(); } return new Pair<String, String>(pgnOrFen, filename); }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.button_add_device) addDevice();/* www . j a v a 2 s. c om*/ else if (itemId == R.id.button_about) { mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.button_about) .setMessage(R.string.about) .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickinstaller) .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); final String installer_file = getResources() .getStringArray(R.array.installer_values)[which]; mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickdownloader) .setItems(R.array.download_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String action = getResources().getStringArray( R.array.download_values)[which]; if (ACTION_DOWNLOAD_SDCARD.equals(action) && copyFileToSDCard(installer_file)) Toast.makeText(TapLockSettings.this, "Done!", Toast.LENGTH_SHORT).show(); else if (ACTION_DOWNLOAD_EMAIL.equals(action) && copyFileToSDCard(installer_file)) { Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); emailIntent.setType( "application/java-archive"); emailIntent.putExtra(Intent.EXTRA_TEXT, getString( R.string.email_instructions)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + Environment .getExternalStorageDirectory() .getPath() + "/" + installer_file)); startActivity(Intent.createChooser( emailIntent, getString( R.string.button_getserver))); } } }) .create(); mDialog.show(); } }).create(); mDialog.show(); } }).setPositiveButton(R.string.button_license, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.button_license).setMessage(R.string.license).create(); mDialog.show(); } }).create(); mDialog.show(); } return super.onOptionsItemSelected(item); }
From source file:com.dycody.android.idealnote.DetailFragment.java
/** * Performs an action when long-click option is selected * * @param attachmentPosition// w ww .ja va 2 s . c o m * @param i item index */ private void performAttachmentAction(int attachmentPosition, int i) { switch (getResources().getStringArray(R.array.attachments_actions_values)[i]) { case "share": Intent shareIntent = new Intent(Intent.ACTION_SEND); Attachment attachment = mAttachmentAdapter.getItem(attachmentPosition); shareIntent.setType(StorageHelper.getMimeType(IdealNote.getAppContext(), attachment.getUri())); shareIntent.putExtra(Intent.EXTRA_STREAM, attachment.getUri()); if (IntentChecker.isAvailable(IdealNote.getAppContext(), shareIntent, null)) { startActivity(shareIntent); } else { Toast.makeText(getActivity(), R.string.feature_not_available_on_this_device, Toast.LENGTH_SHORT) .show(); //mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.WARN); } break; case "delete": removeAttachment(attachmentPosition); mAttachmentAdapter.notifyDataSetChanged(); mGridView.autoresize(); break; case "delete all": new MaterialDialog.Builder(mainActivity).title(R.string.delete_all_attachments) .positiveText(R.string.confirm) .onPositive((materialDialog, dialogAction) -> removeAllAttachments()).build().show(); break; case "edit": takeSketch(mAttachmentAdapter.getItem(attachmentPosition)); break; default: Log.w(Constants.TAG, "No action available"); } }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void sendLogFile(final CommonLogFileListAdapter lfm_adapter) { final String zip_file_name = mGp.getLogDirName() + "log.zip"; int no_of_files = 0; for (int i = 0; i < lfm_adapter.getCount(); i++) { if (lfm_adapter.getItem(i).isChecked) no_of_files++;// w ww.ja v a 2s . c o m } final String[] file_name = new String[no_of_files]; int files_pos = 0; for (int i = 0; i < lfm_adapter.getCount(); i++) { if (lfm_adapter.getItem(i).isChecked) { file_name[files_pos] = lfm_adapter.getItem(i).log_file_path; files_pos++; } } final ThreadCtrl tc = new ThreadCtrl(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { } @Override public void negativeResponse(Context c, Object[] o) { tc.setDisabled(); } }); final ProgressBarDialogFragment pbdf = ProgressBarDialogFragment.newInstance( mContext.getString(R.string.msgs_log_file_list_dlg_send_zip_file_creating), "", mContext.getString(R.string.msgs_common_dialog_cancel), mContext.getString(R.string.msgs_common_dialog_cancel)); pbdf.showDialog(getFragmentManager(), pbdf, ntfy, true); Thread th = new Thread() { @Override public void run() { File lf = new File(zip_file_name); lf.delete(); String[] lmp = LocalMountPoint.convertFilePathToMountpointFormat(mContext, file_name[0]); ZipUtil.createZipFile(mContext, tc, pbdf, zip_file_name, lmp[0], file_name); if (tc.isEnabled()) { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_SEND); // intent.setType("message/rfc822"); // intent.setType("text/plain"); intent.setType("application/zip"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(lf)); mFragment.getActivity().startActivity(intent); mUiHandler.post(new Runnable() { @Override public void run() { lfm_adapter.setAllItemChecked(false); lfm_adapter.setShowCheckBox(false); lfm_adapter.notifyDataSetChanged(); setContextButtonNormalMode(lfm_adapter); } }); } else { lf.delete(); MessageDialogFragment mdf = MessageDialogFragment.newInstance(false, "W", mContext.getString(R.string.msgs_log_file_list_dlg_send_zip_file_cancelled), ""); mdf.showDialog(mFragment.getFragmentManager(), mdf, null); } pbdf.dismiss(); }; }; th.start(); }
From source file:com.ubuntuone.android.files.activity.PreferencesActivity.java
private void sendLogs() { if (ConfigUtilities.isExternalStorageMounted()) { final String details = getDetails(); final File logFile = getLogFile(); final Uri uri = Uri.fromFile(logFile); if (logFile.exists()) { final Intent email = new Intent(Intent.ACTION_SEND); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[] { LOG_EMAIL_TARGET }); email.putExtra(Intent.EXTRA_SUBJECT, LOG_EMAIL_SUBJECT); email.putExtra(Intent.EXTRA_TEXT, details); email.putExtra(Intent.EXTRA_STREAM, uri); startActivity(email);/*w w w . j av a 2 s . co m*/ mCollectLogs.setChecked(false); } } }
From source file:im.neon.fragments.VectorMessageListFragment.java
/*** * Manage save / share / forward actions on a media file * * @param menuAction the menu action ACTION_VECTOR__XXX * @param mediaUrl the media URL (must be not null) * @param mediaMimeType the mime type//w w w. ja va2s.c o m * @param filename the filename */ protected void onMediaAction(final int menuAction, final String mediaUrl, final String mediaMimeType, final String filename, final EncryptedFileInfo encryptedFileInfo) { MXMediasCache mediasCache = Matrix.getInstance(getActivity()).getMediasCache(); File file = mediasCache.mediaCacheFile(mediaUrl, mediaMimeType); // check if the media has already been downloaded if (null != file) { // download if ((menuAction == ACTION_VECTOR_SAVE) || (menuAction == ACTION_VECTOR_OPEN)) { String savedMediaPath = CommonActivityUtils.saveMediaIntoDownloads(getActivity(), file, filename, mediaMimeType); if (null != savedMediaPath) { if (menuAction == ACTION_VECTOR_SAVE) { Toast.makeText(getActivity(), getText(R.string.media_slider_saved), Toast.LENGTH_LONG) .show(); } else { CommonActivityUtils.openMedia(getActivity(), savedMediaPath, mediaMimeType); } } } else { // shared / forward Uri mediaUri = null; File renamedFile = file; if (!TextUtils.isEmpty(filename)) { try { InputStream fin = new FileInputStream(file); String tmpUrl = mediasCache.saveMedia(fin, filename, mediaMimeType); if (null != tmpUrl) { renamedFile = mediasCache.mediaCacheFile(tmpUrl, mediaMimeType); } } catch (Exception e) { Log.e(LOG_TAG, "onMediaAction shared / forward failed : " + e.getLocalizedMessage()); } } if (null != renamedFile) { try { mediaUri = VectorContentProvider.absolutePathToUri(getActivity(), renamedFile.getAbsolutePath()); } catch (Exception e) { Log.e(LOG_TAG, "onMediaAction VectorContentProvider.absolutePathToUri: " + e.getLocalizedMessage()); } } if (null != mediaUri) { final Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType(mediaMimeType); sendIntent.putExtra(Intent.EXTRA_STREAM, mediaUri); if (menuAction == ACTION_VECTOR_FORWARD) { CommonActivityUtils.sendFilesTo(getActivity(), sendIntent); } else { startActivity(sendIntent); } } } } else { // else download it final String downloadId = mediasCache.downloadMedia(getActivity(), mSession.getHomeserverConfig(), mediaUrl, mediaMimeType, encryptedFileInfo); mAdapter.notifyDataSetChanged(); if (null != downloadId) { mediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() { @Override public void onDownloadError(String downloadId, JsonElement jsonElement) { MatrixError error = JsonUtils.toMatrixError(jsonElement); if ((null != error) && error.isSupportedErrorCode()) { Toast.makeText(VectorMessageListFragment.this.getActivity(), error.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(downloadId)) { VectorMessageListFragment.this.getActivity().runOnUiThread(new Runnable() { @Override public void run() { onMediaAction(menuAction, mediaUrl, mediaMimeType, filename, encryptedFileInfo); } }); } } }); } } }