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:net.frakbot.FWeather.util.FeedbackService.java
/** * Sends a feedback email (fallback for when the Android feedback mechanism * doesn't work or isn't available).//from www. ja v a 2s . c o m */ private void sendFeedbackEmail() { Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "frakbot+fweather@gmail.com" }); email.putExtra(Intent.EXTRA_SUBJECT, "[FEEDBACK] " + getString(R.string.app_name)); email.setType("message/rfc822"); final File logFile = collectLogcat(); if (logFile != null && logFile.exists()) { email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(logFile)); email.putExtra(Intent.EXTRA_TEXT, generateFeedbackBody()); } else { email.putExtra(Intent.EXTRA_TEXT, "\n\nCouldn't attach logcat\n\n" + generateFeedbackBody()); } try { FLog.i(TAG, "Sending feedback email"); startActivity(Intent.createChooser(email, getString(R.string.feedback_send_chooser_title)) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); stopForeground(true); } catch (Exception e) { Toast.makeText(this, getString(R.string.toast_feedback_mail_error), Toast.LENGTH_LONG).show(); FLog.e(TAG, "Unable to send the feedback email", e); stopForeground(true); } }
From source file:com.activiti.android.app.fragments.content.ContentsFragment.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;/*from w w w. j a v a 2s. c o m*/ } if (waitingDialog != null) { waitingDialog.dismiss(); } 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.example.office.ui.Office365DemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {/*from www. j a va 2s. co m*/ Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); //Processing system intent of sharing an image if (Intent.ACTION_SEND.equals(action) && type != null) { if (type.startsWith("image/")) { Bundle bundle = intent.getExtras(); Uri uri = (Uri) bundle.get(Intent.EXTRA_STREAM); // Retrieving path to the image and attaching it to current intent attachImageToCurrentEvent(Utility.getRealPathFromURI(uri, this), type); } } if (savedInstanceState == null) { mSavedFragmentTag = null; } else { mSavedFragmentTag = savedInstanceState.getString(STATE_FRAGMENT_TAG); } setConfiguration(); } catch (Exception e) { Logger.logApplicationException(e, getClass().getSimpleName() + ".onNewIntent(): Error."); } }
From source file:edu.ksu.cs.a4vm.bse.EditCollections.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_collections); Intent i = getIntent();//from w w w . ja v a 2 s . c o m Bundle extras = i.getExtras(); ranchInfo = extras.getString("ranch"); grpId = extras.getString("GrpId"); String name = null; String dateColleted = null; TextView tvRanch = (TextView) findViewById(R.id.ranchName); TextView tvDate = (TextView) findViewById(R.id.ranchDate); TextView tvBull = (TextView) findViewById(R.id.editBulls); TextView tvExport = (TextView) findViewById(R.id.export); TextView tvEditGrp = (TextView) findViewById(R.id.editGrp); permission = ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE); //TextView tvDelete = (TextView) findViewById(R.id.deleteGrp); if (ranchInfo != null) { dateColleted = ranchInfo.substring(0, ranchInfo.indexOf(":")); name = ranchInfo.substring(ranchInfo.indexOf(":") + 1, ranchInfo.length()); } tvRanch.setText(name); tvDate.setText(dateColleted); tvBull.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent goToMorph = new Intent(getApplicationContext(), BullGroup.class); Bundle items = new Bundle(); items.putString("ranch", ranchInfo); items.putString("grpId", grpId); goToMorph.putExtras(items); startActivity(goToMorph); } }); tvEditGrp.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent goToMorph = new Intent(getApplicationContext(), NewGroup.class); goToMorph.putExtra("grpKey", grpId); startActivity(goToMorph); } }); tvExport.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (permission != PackageManager.PERMISSION_GRANTED) { // We don't have permission so prompt the user ActivityCompat.requestPermissions(EditCollections.this, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE); } else { File file; File root = Environment.getExternalStorageDirectory(); File dir = new File(root.getAbsolutePath() + "/bull_collections"); dir.mkdirs(); file = new File(dir, "Data.csv"); try { if (!file.exists()) { file.createNewFile(); } FileOutputStream out = null; out = new FileOutputStream(file); String head = Constant.CSV_HEADING; ArrayList<ArrayList> list = CreateCSV.getData(getApplicationContext(), grpId); if (Constant.morphHeaders != null) { for (int i = 0; i < Constant.morphHeaders.size(); i++) { head = head + Constant.morphHeaders.get(i) + ","; } } out.write(head.getBytes()); if (list != null) { for (int i = 0; i < list.size(); i++) { out.write("\n".getBytes()); ArrayList<String> row = list.get(i); String contents; if (row != null) { contents = row.get(0); for (int j = 1; j < 103; j++) { contents = contents + "," + row.get(j); } out.write(contents.getBytes()); } } } out.close(); } catch (IOException e) { Log.e(Constant.CSV_MSG, "File writing error"); e.printStackTrace(); } Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Exported file"); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); sendIntent.setType("text/html"); startActivityForResult(sendIntent, 119); } //if (root.canWrite()){ //} /*else { Toast.makeText(getApplicationContext(),"Failed to mount dir!",Toast.LENGTH_SHORT).show(); }*/ } }); }
From source file:cn.figo.mydemo.ui.activity.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"); 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();/*from w ww . j av a2s. c om*/ 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; } } Intent intent = getIntent(); 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); new RecentMediaStorage(this).saveUrlAsync(mVideoPath); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); mVideoView.toggleAspectRatio(); if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } initDanmaku(); }
From source file:com.samuelcastro.cordova.InstagramSharePlugin.java
private void shareVideo(String videoString, String captionString) { // Create the URI from the media File media = new File(this.getRealVideoPathFromURI(Uri.parse(videoString))); Uri uri = Uri.fromFile(media);/*from ww w.j av a 2s. c om*/ Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("video/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, captionString); shareIntent.setPackage("com.instagram.android"); this.cordova.startActivityForResult((CordovaPlugin) this, shareIntent, 12345); }
From source file:edu.stanford.junction.sample.partyware.ImgurUploadService.java
/** * /*from w w w . j av a 2 s . c om*/ * @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()); 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.bringcommunications.etherpay.ReceiveActivity.java
private void do_share_guts() { Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/*"); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); qr_bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = null;// ww w .ja v a 2 s. c o m try { path = MediaStore.Images.Media.insertImage(getContentResolver(), qr_bitmap, "QR Code", null); if (path == null) { //turns out there's an Android bug, where it happens when the user hasn't taken a photo on the device before (i.e. gallery is empty //and hasn't been initialized.). The workaround is to initialize the photo directory manually: File sdcard = Environment.getExternalStorageDirectory(); if (sdcard != null) { File mediaDir = new File(sdcard, "DCIM/Camera"); if (!mediaDir.exists()) mediaDir.mkdirs(); } path = MediaStore.Images.Media.insertImage(getContentResolver(), qr_bitmap, "QR Code", null); } } catch (Exception e) { } if (path == null) { String msg = getResources().getString(R.string.receive_err_no_media_access_msg); Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); return; } Uri imageUri = Uri.parse(path); share.putExtra(Intent.EXTRA_STREAM, imageUri); if (show_private) share.putExtra(Intent.EXTRA_TEXT, private_key); else share.putExtra(Intent.EXTRA_TEXT, acct_addr); try { startActivity(Intent.createChooser(share, "Select")); } catch (android.content.ActivityNotFoundException ex) { ex.printStackTrace(); } }
From source file:com.xengar.android.booksearch.ui.BookDetailActivity.java
private void setShareIntent() { ImageView ivImage = (ImageView) findViewById(R.id.ivBookCover); final TextView tvTitle = (TextView) findViewById(R.id.tvTitle); // Get access to the URI for the bitmap Uri bmpUri = getLocalBitmapUri(ivImage); // Construct a ShareIntent with link to image Intent shareIntent = new Intent(); // Construct a ShareIntent with link to image shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("*/*"); shareIntent.putExtra(Intent.EXTRA_TEXT, (String) tvTitle.getText()); shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); // Launch share menu startActivity(Intent.createChooser(shareIntent, "Share Image")); }
From source file:de.dreier.mytargets.features.scoreboard.ScoreboardActivity.java
private void shareImage() { // Construct share intent new AsyncTask<Void, Void, Uri>() { @Override/*w ww. j a v a 2s . c o m*/ protected Uri doInBackground(Void... objects) { try { File dir = getCacheDir(); final File f = File.createTempFile("scoreboard", ".png", dir); new ScoreboardImage().generateBitmap(ScoreboardActivity.this, mTraining, mRound, f); String packageName = getApplicationContext().getPackageName(); String authority = packageName + ".easyphotopicker.fileprovider"; return getUriForFile(ScoreboardActivity.this, authority, f); } catch (IOException e) { e.printStackTrace(); return null; } } @Override protected void onPostExecute(Uri uri) { super.onPostExecute(uri); if (uri == null) { Snackbar.make(binding.getRoot(), R.string.sharing_failed, Snackbar.LENGTH_SHORT).show(); } else { // Build and fire intent to ask for share provider Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("*/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(shareIntent, getString(R.string.share))); } } }.execute(); }