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.appplant.cordova.emailcomposer.EmailComposerImpl.java
/** * Setter for the attachments.//from w w w . j av a 2 s.c om * * @param attachments * List of URIs to attach. * @param draft * The intent to send. * @param ctx * The application context. * @throws JSONException */ private void setAttachments(JSONArray attachments, Intent draft, Context ctx) throws JSONException { ArrayList<Uri> uris = new ArrayList<Uri>(); for (int i = 0; i < attachments.length(); i++) { Uri uri = getUriForPath(attachments.getString(i), ctx); uris.add(uri); } draft.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); }
From source file:de.schildbach.wallet.ui.ReportIssueDialogBuilder.java
private void startSend(final CharSequence subject, final CharSequence text, final ArrayList<Uri> attachments) { final Intent intent; if (attachments.size() == 0) { intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); } else if (attachments.size() == 1) { intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_STREAM, attachments.get(0)); } else {/* www . jav a2 s. c o m*/ intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("text/plain"); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments); } intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.REPORT_EMAIL }); if (subject != null) intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { context.startActivity(Intent.createChooser(intent, context.getString(R.string.report_issue_dialog_mail_intent_chooser))); log.info("invoked chooser for sending issue report"); } catch (final Exception x) { Toast.makeText(context, R.string.report_issue_dialog_mail_intent_failed, Toast.LENGTH_LONG).show(); log.error("report issue failed", x); } }
From source file:com.maass.android.imgur_uploader.ImgurUpload.java
/** * /* ww w . j av a 2 s . c o m*/ * @return a map that contains objects with the following keys: * * delete - the url used to delete the uploaded image (null if * error). * * original - the url to the uploaded image (null if error) The map * is null if error */ private Map<String, String> handleSendIntent(final Intent intent) { Log.i(this.getClass().getName(), "in handleResponse()"); Log.d(this.getClass().getName(), intent.toString()); final Bundle extras = intent.getExtras(); try { //upload a new image if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null) && extras.containsKey(Intent.EXTRA_STREAM)) { final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (uri != null) { Log.d(this.getClass().getName(), uri.toString()); // store uri so we can create the thumbnail if we succeed imageLocation = uri; final String jsonOutput = readPictureDataAndUpload(uri); return parseJSONResponse(jsonOutput); } Log.e(this.getClass().getName(), "URI null"); } } catch (final Exception e) { Log.e(this.getClass().getName(), "Completely unexpected error", e); } return null; }
From source file:com.zertinteractive.wallpaper.activities.DetailActivity.java
public void setAsWallpaper(long mImageId) { if (mImageId == -1) { setAsWallpaperMore();// w w w.j a va 2 s. c o m } else { Intent intent = new Intent(DetailActivity.this, SetWallpaperActivity.class); Uri base_uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; Uri item_uri = ContentUris.withAppendedId(base_uri, mImageId); intent.putExtra(Intent.EXTRA_STREAM, item_uri); Cursor cur = getContentResolver().query(item_uri, null, null, null, null); if (cur.moveToFirst()) { int colMimetype = cur.getColumnIndex(MediaStore.Images.ImageColumns.MIME_TYPE); intent.setDataAndType(item_uri, cur.getString(colMimetype)); } cur.close(); startActivity(intent); } }
From source file:com.jecelyin.android.file_explorer.FileExplorerAction.java
private void shareFile() { if (checkedList.isEmpty() || shareActionProvider == null) return;//from w w w. j a v a 2 s . c o m Intent shareIntent = new Intent(); if (checkedList.size() == 1) { File localFile = new File(checkedList.get(0).getPath()); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType(MimeTypes.getInstance().getMimeType(localFile.getPath())); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(localFile)); } else { shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); ArrayList<Uri> streams = new ArrayList<>(); for (JecFile file : checkedList) { if (!(file instanceof LocalFile)) throw new ExplorerException( context.getString(R.string.can_not_share_x, file + " isn't LocalFile")); streams.add(Uri.fromFile(new File(file.getPath()))); } shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, streams); } shareActionProvider.setShareIntent(shareIntent); }
From source file:org.alfresco.mobile.android.application.fragments.upload.UploadFormFragment.java
@Override public void onStart() { super.onStart(); Intent intent = getActivity().getIntent(); String action = intent.getAction(); String type = intent.getType(); if (files != null) { files.clear();//from w ww . java 2s .c om } try { if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { if (AndroidVersion.isJBOrAbove()) { ClipData clipdata = intent.getClipData(); if (clipdata != null && clipdata.getItemCount() > 1) { Item item = null; for (int i = 0; i < clipdata.getItemCount(); i++) { item = clipdata.getItemAt(i); Uri uri = item.getUri(); if (uri != null) { retrieveIntentInfo(uri); } else { String timeStamp = new SimpleDateFormat("yyyyddMM_HHmmss").format(new Date()); File localParentFolder = StorageManager.getCacheDir(getActivity(), "AlfrescoMobile/import"); File f = createFile(localParentFolder, timeStamp + ".txt", item.getText().toString()); if (f.exists()) { retrieveIntentInfo(Uri.fromFile(f)); } } if (!files.contains(file)) { files.add(file); } } } } else { if (intent.getExtras() != null && intent.getExtras().get(Intent.EXTRA_STREAM) instanceof ArrayList) { @SuppressWarnings("unchecked") List<Object> attachments = (ArrayList<Object>) intent.getExtras().get(Intent.EXTRA_STREAM); for (Object object : attachments) { if (object instanceof Uri) { Uri uri = (Uri) object; if (uri != null) { retrieveIntentInfo(uri); } if (!files.contains(file)) { files.add(file); } } } } else if (file == null || fileName == null) { MessengerManager.showLongToast(getActivity(), getString(R.string.import_unsupported_intent)); getActivity().finish(); return; } } } else { // Manage only one clip data. If multiple we ignore. if (AndroidVersion.isJBOrAbove() && (!Intent.ACTION_SEND.equals(action) || type == null)) { ClipData clipdata = intent.getClipData(); if (clipdata != null && clipdata.getItemCount() == 1 && clipdata.getItemAt(0) != null && (clipdata.getItemAt(0).getText() != null || clipdata.getItemAt(0).getUri() != null)) { Item item = clipdata.getItemAt(0); Uri uri = item.getUri(); if (uri != null) { retrieveIntentInfo(uri); } else { String timeStamp = new SimpleDateFormat("yyyyddMM_HHmmss").format(new Date()); File localParentFolder = StorageManager.getCacheDir(getActivity(), "AlfrescoMobile/import"); File f = createFile(localParentFolder, timeStamp + ".txt", item.getText().toString()); if (f.exists()) { retrieveIntentInfo(Uri.fromFile(f)); } } } } if (file == null && Intent.ACTION_SEND.equals(action) && type != null) { Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); retrieveIntentInfo(uri); } else if (action == null && intent.getData() != null) { retrieveIntentInfo(intent.getData()); } else if (file == null || fileName == null) { MessengerManager.showLongToast(getActivity(), getString(R.string.import_unsupported_intent)); getActivity().finish(); return; } if (!files.contains(file)) { files.add(file); } } } catch (AlfrescoAppException e) { org.alfresco.mobile.android.application.manager.ActionManager.actionDisplayError(this, e); getActivity().finish(); return; } if (adapter == null && files != null) { adapter = new FileExplorerAdapter(this, R.layout.app_list_progress_row, files); if (lv != null) { lv.setAdapter(adapter); } else if (spinnerDoc != null) { spinnerDoc.setAdapter(adapter); } } Button b = UIUtils.initCancel(rootView, R.string.cancel); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().finish(); } }); b = UIUtils.initValidation(rootView, R.string.next); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { next(); } }); refreshImportFolder(); }
From source file:com.cmput301.recipebot.ui.AbstractRecipeActivity.java
/** * Creates a sharing {@link android.content.Intent}. * Shares mRecipe, doesn't get it from the UI. * * @return The sharing intent.//w w w . j a v a 2 s. c o m */ private static Intent createShareIntent(Recipe recipe, File file) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_SUBJECT, recipe.getName()); shareIntent.putExtra(Intent.EXTRA_TITLE, recipe.getName()); shareIntent.putExtra(Intent.EXTRA_TEXT, recipe.toEmail()); shareIntent.setType("application/json"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); return shareIntent; }
From source file:de.domjos.schooltools.helper.Helper.java
public static void sendMailWithAttachment(String email, String subject, File file, Context context) { Uri attachment = FileProvider.getUriForFile(context, context.getPackageName() + ".my.package.name.provider", file);// ww w . j av a 2s . c o m Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("vnd.android.cursor.dir/email"); String[] to = { email }; intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_STREAM, attachment); intent.putExtra(Intent.EXTRA_SUBJECT, subject); context.startActivity(Intent.createChooser(intent, "Send email...")); }
From source file:com.christophergs.mbientbasic.SensorFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (sensorResId != 2131165359) { chart = (LineChart) view.findViewById(R.id.data_chart); initializeChart();/*from w w w . j a v a 2s .c om*/ resetData(false); chart.invalidate(); chart.setDescription(null); Button clearButton = (Button) view.findViewById(R.id.layout_two_button_left); clearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { refreshChart(true); } }); clearButton.setText(R.string.label_clear); } else { Log.i(TAG, "Pie Chart"); } ((Switch) view.findViewById(R.id.sample_control)) .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { moveViewToLast(); setup(); chartHandler.postDelayed(updateChartTask, UPDATE_PERIOD); } else { chart.setVisibleXRangeMaximum(sampleCount); clean(); if (streamRouteManager != null) { streamRouteManager.remove(); streamRouteManager = null; } chartHandler.removeCallbacks(updateChartTask); } } }); Button chartButton = (Button) view.findViewById(R.id.layout_two_button_center); chartButton.setText(R.string.label_pie); Button saveButton = (Button) view.findViewById(R.id.layout_two_button_right); saveButton.setText(R.string.label_save); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String filename = saveData(false); if (filename != null) { File dataFile = getActivity().getFileStreamPath(filename); Uri contentUri = FileProvider.getUriForFile(getActivity(), "com.mbientlab.metawear.app.fileprovider2", dataFile); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, filename); intent.putExtra(Intent.EXTRA_STREAM, contentUri); startActivity(Intent.createChooser(intent, "Saving Data")); } } }); }