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:it.smartcampuslab.riciclo.FeedbackFragment.java
@Override public void onStart() { super.onStart(); ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle(getString(R.string.feedback_title)); Button send = (Button) getView().findViewById(R.id.feedback_btn); send.setOnClickListener(new OnClickListener() { @Override/*from w w w . j av a 2s . c o m*/ public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getString(R.string.feedback_to), null)); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject)); String text = ((EditText) getView().findViewById(R.id.feedback_text_et)).getText().toString(); if (RifiutiHelper.locationHelper.getLocation() != null) { mLocation = RifiutiHelper.locationHelper.getLocation(); text += " \n\n[" + mLocation.getLatitude() + "," + mLocation.getLongitude() + "]"; Log.e(getClass().getSimpleName(), "Feedback text: " + text); } intent.putExtra(Intent.EXTRA_TEXT, text); if (imageUri != null) { // intent.setType("application/image"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageUri)); } getActivity().startActivity(Intent.createChooser(intent, getString(R.string.feedback_mail))); } }); OnClickListener clickListener = new OnClickListener() { @Override public void onClick(View v) { startCamera(); } }; getView().findViewById(R.id.feedback_img).setOnClickListener(clickListener); getView().findViewById(R.id.feedback_img_text).setOnClickListener(clickListener); CheckBox check = (CheckBox) getView().findViewById(R.id.feedback_gps); if (check.isChecked()) { useLocation = true; } check.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { useLocation = isChecked; if (isChecked) { // getActivity().setProgressBarIndeterminateVisibility(true); RifiutiHelper.locationHelper.start(); } else { RifiutiHelper.locationHelper.stop(); // getActivity().setProgressBarIndeterminateVisibility(false); } } }); }
From source file:com.samuelcastro.cordova.InstagramSharePlugin.java
private void shareImage(String imageString, String captionString) { if (imageString != null && imageString.length() > 0) { byte[] imageData = Base64.decode(imageString, 0); File file = null;/*from w ww . j a va 2 s . c om*/ FileOutputStream os = null; File parentDir = this.webView.getContext().getExternalFilesDir(null); File[] oldImages = parentDir.listFiles(OLD_IMAGE_FILTER); for (File oldImage : oldImages) { oldImage.delete(); } try { file = File.createTempFile("instagram", ".png", parentDir); os = new FileOutputStream(file, true); } catch (Exception e) { e.printStackTrace(); } try { os.write(imageData); os.flush(); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file)); shareIntent.putExtra(Intent.EXTRA_TEXT, captionString); shareIntent.setPackage("com.instagram.android"); this.cordova.startActivityForResult((CordovaPlugin) this, shareIntent, 12345); } else { this.cbContext.error("Expected one non-empty string argument."); } }
From source file:com.android.messaging.ui.photoviewer.BuglePhotoViewController.java
private void updateShareActionProvider() { final PhotoPagerAdapter adapter = getAdapter(); final Cursor cursor = getCursorAtProperPosition(); if (mShareActionProvider == null || mShareItem == null || adapter == null || cursor == null) { // Not enough stuff loaded to update the share action return;/* w w w . j a va2 s .com*/ } final String photoUri = adapter.getPhotoUri(cursor); if (isTempFile()) { mShareItem.setVisible(false); return; } final String contentType = adapter.getContentType(cursor); final Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType(contentType); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(photoUri)); mShareActionProvider.setShareIntent(shareIntent); mShareItem.setVisible(true); }
From source file:com.ushahidi.android.app.activities.BaseMapActivity.java
protected void sharePhoto(String path) { // TODO: consider bringing in shortlink to session Preferences.loadSettings(this); final String reportUrl = Preferences.domain; final String shareString = getString(R.string.share_template, "", reportUrl); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpg"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path)); intent.putExtra(Intent.EXTRA_TEXT, shareString); startActivityForResult(Intent.createChooser(intent, getText(R.string.title_share)), 0); setResult(RESULT_OK);// www.j a v a2s. c om }
From source file:com.cryart.sabbathschool.util.SSNotification.java
public static void showLessonNotification(Context context) { SSCore _SSCore = SSCore.getInstance(context); if (!SSCore.databaseExists()) return;/*from ww w. ja v a 2s. com*/ try { SSDay _SSDay = _SSCore.ssGetDay(_SSCore.ssTodaysDate()); Bitmap _SSLessonBitmap = SSHelper.getBitmapFromBase64(_SSDay._lesson_image); NotificationManager _SSNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent _SSContentIntent = new Intent(context, SSLoadingActivity.class); Intent _SSShareIntent = new Intent(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); String _SSBitmapLocation = Environment.getExternalStorageDirectory().toString() + "/" + SSConstants.SS_NOTIFICATION_LESSON_HERO_TMP_FILENAME; _SSContentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); _SSShareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); _SSShareIntent.setAction(Intent.ACTION_SEND); _SSShareIntent.putExtra(Intent.EXTRA_TEXT, _SSDay._day_name + " " + SSConstants.SS_SHARE_FB_LINK); _SSLessonBitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes); File f = new File(_SSBitmapLocation); try { f.createNewFile(); FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); } catch (IOException e) { e.printStackTrace(); } _SSShareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + _SSBitmapLocation)); _SSShareIntent.setType("*/*"); PendingIntent _SSPendingContentIntent = PendingIntent.getActivity(context, 0, _SSContentIntent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent _SSPendingShareIntent = PendingIntent.getActivity(context, 0, Intent.createChooser(_SSShareIntent, "Share lesson to:"), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder _SSNotificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ss_app_icon_notification) .setColor(context.getResources().getColor(R.color.ss_primary)).setLargeIcon(_SSLessonBitmap) .setContentTitle(_SSDay._day_name) .setStyle(new NotificationCompat.BigPictureStyle().setBigContentTitle(_SSDay._day_name) .setSummaryText(_SSDay._day_name).bigPicture(_SSLessonBitmap)) .addAction(R.drawable.ss_ic_book_grey600_24dp, context.getString(R.string.ss_notification_read_lesson), _SSPendingContentIntent) .addAction(R.drawable.ss_ic_share_white_24dp, context.getString(R.string.ss_notification_share_lesson), _SSPendingShareIntent) .setAutoCancel(true).setContentIntent(_SSPendingContentIntent).setContentText(_SSDay._day_name); _SSNotificationManager.notify(1, _SSNotificationBuilder.build()); } catch (Exception e) { } }
From source file:de.zweipunktfuenf.crypdroid.activities.ActionChooserActivity.java
public void onClickSendAttachment(View clicked) { Intent send = new Intent(Intent.ACTION_SEND); send.putExtra(Intent.EXTRA_STREAM, Uri.parse(CrypProvider.URI + CrypProvider.FILE_ENCRYPTED)); send.setType(CIPHER_MIME_TYPE);//from w w w . j a va 2s.c om // can't use this, because FLAG_GRANT_READ_URI_PERMISSION only grants read permission // for the URI in setData and setData sets the receiver for an email // send.setData(Uri.parse(CrypProvider.URI)); // send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // for API 16 and greater it should be possible to use // setClipData instead of setData and therefore avoid the problem // since FLAG_GRANT_READ_URI_PERMISSION also grants permissions // for URIs included in the Intent as clip-data // send.setClipData(new ClipData( // "data_uri", // new String[] {"text/plain"}, // new ClipData.Item(Uri.parse(CrypProvider.URI)) // )); // cannot manually grant the read permission because I don't know the // third party App URI in advance // getApplicationContext().grantUriPermission("com.package.viewer", Uri.parse(CrypProvider.URI), Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(send, getString(R.string.send_with))); }
From source file:mobisocial.bento.anyshare.ui.FeedItemListActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent ret) { if (requestCode == REQUEST_PICK) { if (resultCode == RESULT_OK) { Log.d(TAG, ret.toString());// w w w . j a v a 2 s . co m Uri uri = ret.getData(); Intent intent = new Intent(this, PostActivity.class); intent.setAction(Intent.ACTION_SEND); String mimetype = getContentResolver().getType(uri); String ext = MimeTypeMap.getFileExtensionFromUrl(uri.toString()); MimeTypeMap mime = MimeTypeMap.getSingleton(); if (mimetype == null || mimetype.isEmpty()) { if (!ext.isEmpty()) { mimetype = mime.getMimeTypeFromExtension(ext); } } String fname = uri.getLastPathSegment(); if (ext.isEmpty()) { fname += "." + mime.getExtensionFromMimeType(mimetype); } intent.setType(mimetype); intent.putExtra(Intent.EXTRA_SUBJECT, fname); intent.putExtra(Intent.EXTRA_TEXT, ""); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivityForResult(intent, HomeActivity.REQUEST_VIEW); } } super.onActivityResult(requestCode, resultCode, ret); }
From source file:com.f2prateek.dfg.core.GenerateFrameService.java
@Override public void doneImage(final Uri imageUri) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override//w w w. ja va 2 s. c o m public void run() { bus.post(new Events.SingleImageProcessed(device, imageUri)); } }); // Create the intent to let the user share the image Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri); Intent chooserIntent = Intent.createChooser(sharingIntent, null); chooserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); notificationBuilder.addAction(R.drawable.ic_action_share, getResources().getString(R.string.share), PendingIntent.getActivity(this, 0, chooserIntent, PendingIntent.FLAG_CANCEL_CURRENT)); // Create the intent to let the user rate the app Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstants.MARKET_URL)); notificationBuilder.addAction(R.drawable.ic_action_rate, getResources().getString(R.string.rate), PendingIntent.getActivity(this, 0, rateIntent, PendingIntent.FLAG_CANCEL_CURRENT)); // Create the intent to show the screenshot in gallery Intent launchIntent = new Intent(Intent.ACTION_VIEW); launchIntent.setDataAndType(imageUri, "image/png"); launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationBuilder.setContentTitle(resources.getString(R.string.screenshot_saved_title)) .setContentText(resources.getString(R.string.single_screenshot_saved, device.name())) .setContentIntent(PendingIntent.getActivity(this, 0, launchIntent, 0)) .setWhen(System.currentTimeMillis()).setProgress(0, 0, false).setAutoCancel(true); notificationManager.notify(DFG_NOTIFICATION_ID, notificationBuilder.build()); }
From source file:at.wada811.utils.IntentUtils.java
/** * Intent??// ww w.ja v a 2 s. c om * * @param intent * @param uri * @param mimeType * @return */ public static Intent addFile(Intent intent, Uri uri, String mimeType) { intent.setType(mimeType); intent.putExtra(Intent.EXTRA_STREAM, uri); return intent; }
From source file:com.udacity.movietimes.activities.MainActivity.java
/** * This is Callback interface interface method which helps to communicate between two different fragments by passing * movieId values./* w w w. j a va 2 s.c om*/ * @param movieId */ @Override public void onItemSelected(String movieId) { if (mTwoPane) { Bundle bundle = new Bundle(); bundle.putString(DetailFragment.DETAIL_MOVIE_ID, movieId); DetailFragment fragment = new DetailFragment(); fragment.setArguments(bundle); getSupportFragmentManager().beginTransaction() .replace(R.id.detail_fragment_container, fragment, DETAILFRAGMENT_TAG).commit(); } else { Intent intent = new Intent(this, DetailActivity.class); intent.putExtra(Intent.EXTRA_STREAM, movieId); startActivity(intent); } }