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:Main.java
/** * Helper method for sharing an image.// w w w. j a v a2 s . co m * * @param context The image context. * @param imagePath The path of the image to be shared. */ static void shareImage(Context context, String imagePath) { // Create the share intent and start the share activity File imageFile = new File(imagePath); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); Uri photoURI = FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, imageFile); shareIntent.putExtra(Intent.EXTRA_STREAM, photoURI); context.startActivity(shareIntent); }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);// w ww . ja v a2 s .co m if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text); intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } return intent; }
From source file:Main.java
/** * Send an email via available mail activity * /*from ww w. j a v a 2 s . co m*/ * @param context the app context * @param to the email address send to * @param subject the email subject * @param body the email body * @param attachments the uris for attachments */ public static void sendEmail(Context context, String to, String subject, String body, Uri... attachments) { Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && attachments.length != 0) { ArrayList<Uri> uris = new ArrayList<Uri>(); for (int i = 0; i < attachments.length; i++) uris.add(attachments[i]); emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } context.startActivity(Intent.createChooser(emailIntent, null)); }
From source file:com.contentecontent.cordova.plugins.share.Share.java
private void doSendIntent(String subject, String text, String imagePath, String mimeType) { Uri parsedUri = Uri.parse(imagePath); Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); sendIntent.setType(mimeType);/*ww w. j a va2s . c om*/ sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, text); sendIntent.putExtra(android.content.Intent.EXTRA_STREAM, parsedUri); this.cordova.startActivityForResult(this, sendIntent, 0); }
From source file:am.project.x.utils.ContextUtils.java
/** * ???//from w w w .j a v a 2 s . c o m * * @param context Context * @param subject * @param attachment * @param addresses ? */ public static void sendEmail(Context context, @Nullable String subject, @Nullable Uri attachment, String... addresses) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, addresses); if (subject != null) intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (attachment != null) intent.putExtra(Intent.EXTRA_STREAM, attachment); if (intent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(intent); } }
From source file:com.example.linhdq.test.main_menu.ContactActivity.java
public static Intent getFeedbackIntent(Context context, String subject, File file, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); if (subject != null) { intent.putExtra(Intent.EXTRA_SUBJECT, subject); }/*from w w w . j a v a 2 s . c om*/ if (file.exists()) { final Uri uriForFile = FileProvider.getUriForFile(context, context.getString(R.string.config_share_file_auth), file); intent.putExtra(Intent.EXTRA_STREAM, uriForFile); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } if (body != null) { intent.putExtra(Intent.EXTRA_TEXT, body); } intent.putExtra(Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL }); return intent; }
From source file:com.renard.ocr.main_menu.ContactActivity.java
public static Intent getFeedbackIntent(Context context, String subject, File file, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); if (subject != null) { intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); }/*from w ww . j av a 2s . co m*/ if (file.exists()) { final Uri uriForFile = FileProvider.getUriForFile(context, context.getString(R.string.config_share_file_auth), file); intent.putExtra(Intent.EXTRA_STREAM, uriForFile); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } if (body != null) { intent.putExtra(Intent.EXTRA_TEXT, body); } intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL }); return intent; }
From source file:ca.rmen.android.scrumchatter.export.Export.java
/** * Bring up the chooser to send the file. *///ww w . j av a2 s .c o m static void share(Context context, File file, String mimeType) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.export_message_subject)); sendIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.export_message_body)); Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", file); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); sendIntent.setType(mimeType); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(sendIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); Log.v(TAG, "grant permission to " + packageName); } } context.startActivity( Intent.createChooser(sendIntent, context.getResources().getText(R.string.action_share))); }
From source file:com.example.popularmovies.MovieDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_detail); mContext = getApplicationContext();//from w w w . j av a2 s . co m Intent receivedIntent = getIntent(); if (receivedIntent == null || !receivedIntent.hasExtra(Intent.EXTRA_STREAM)) { showError(); } mMovieSelected = (Movie) receivedIntent.getParcelableExtra(Intent.EXTRA_STREAM); if (mMovieSelected == null) { showError(); } TMDBUtils.fetchImage(mContext, ((ImageView) findViewById(R.id.iv_movie_backdrop)), mMovieSelected.getPosterPath(), TMDBUtils.IMAGE_SIZE.w780); ((TextView) findViewById(R.id.tv_movie_title)).setText(mMovieSelected.getTitle()); ((TextView) findViewById(R.id.tv_movie_release_date)).setText(mMovieSelected.getReleaseDate()); ((TextView) findViewById(R.id.tv_movie_vote_average)) .setText(Double.toString(mMovieSelected.getVoteAverage())); ((TextView) findViewById(R.id.tv_movie_plot_synopsis)).setText(mMovieSelected.getOverview()); }
From source file:com.richtodd.android.quiltdesign.app.OpenRepositoryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_open_repository); Intent intent = getIntent();//from w w w .j a v a 2 s . c o m Bundle extras = intent.getExtras(); if (extras.containsKey(Intent.EXTRA_STREAM)) { Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); try { JSONObject jsonObject = JSONUtility.loadJSONObject(getContentResolver(), uri); m_repository = new JSONRepository(jsonObject, new QuiltDesignThumbnailProvider()); } catch (RepositoryException e) { Handle.asRuntimeError(e); } } m_text_theme_count = (TextView) findViewById(R.id.text_theme_count); m_text_block_count = (TextView) findViewById(R.id.text_block_count); m_text_quilt_count = (TextView) findViewById(R.id.text_quilt_count); m_radio_import_new = (RadioButton) findViewById(R.id.radio_import_new); m_radio_import_replace = (RadioButton) findViewById(R.id.radio_import_replace); m_radio_import_merge = (RadioButton) findViewById(R.id.radio_import_merge); m_button_import = (Button) findViewById(R.id.button_import); m_button_import.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Repository repository = Repository.getDefaultRepository(OpenRepositoryActivity.this); repository.merge(m_repository, getMergeMode()); Toast.makeText(OpenRepositoryActivity.this, getString(R.string.toast_openRepository_success), Toast.LENGTH_SHORT).show(); finish(); } catch (RepositoryException e) { Handle.asRuntimeError(e); } } }); m_button_cancel_import = (Button) findViewById(R.id.button_cancel_import); m_button_cancel_import.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); if (m_repository != null) { try { m_text_theme_count.setText(Integer.toString(m_repository.getThemes().getCount())); m_text_block_count.setText(Integer.toString(m_repository.getBlocks().getCount())); m_text_quilt_count.setText(Integer.toString(m_repository.getQuilts().getCount())); } catch (RepositoryException e) { Handle.asRuntimeError(e); } } else { m_text_theme_count.setText("0"); m_text_block_count.setText("0"); m_text_quilt_count.setText("0"); } }