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:com.nexes.manager.EventHandler.java
/** * This method, handles the button presses of the top buttons found in the * Main activity.//from w w w.j a va2s .com */ @Override public void onClick(View v) { switch (v.getId()) { case R.id.back_button: if (mFileMang.getCurrentDir() != "/") { if (multi_select_flag) { mDelegate.killMultiSelect(true); Toast.makeText(mContext, "Multi-select is now off", Toast.LENGTH_SHORT).show(); } stopThumbnailThread(); updateDirectory(mFileMang.getPreviousDir()); if (mPathLabel != null) mPathLabel.setText(mFileMang.getCurrentDir()); } break; case R.id.home_button: if (multi_select_flag) { mDelegate.killMultiSelect(true); Toast.makeText(mContext, "Multi-select is now off", Toast.LENGTH_SHORT).show(); } stopThumbnailThread(); updateDirectory(mFileMang.setHomeDir("/sdcard")); if (mPathLabel != null) mPathLabel.setText(mFileMang.getCurrentDir()); break; case R.id.info_button: Intent info = new Intent(mContext, DirectoryInfo.class); info.putExtra("PATH_NAME", mFileMang.getCurrentDir()); mContext.startActivity(info); break; case R.id.help_button: Intent help = new Intent(mContext, HelpManager.class); mContext.startActivity(help); break; case R.id.manage_button: display_dialog(MANAGE_DIALOG); break; case R.id.multiselect_button: if (multi_select_flag) { mDelegate.killMultiSelect(true); } else { LinearLayout hidden_lay = (LinearLayout) ((Activity) mContext).findViewById(R.id.hidden_buttons); multi_select_flag = true; hidden_lay.setVisibility(LinearLayout.VISIBLE); } break; /* * three hidden buttons for multiselect */ case R.id.hidden_attach: /* check if user selected objects before going further */ if (mMultiSelectData == null || mMultiSelectData.isEmpty()) { mDelegate.killMultiSelect(true); break; } ArrayList<Uri> uris = new ArrayList<Uri>(); int length = mMultiSelectData.size(); Intent mail_int = new Intent(); mail_int.setAction(android.content.Intent.ACTION_SEND_MULTIPLE); mail_int.setType("application/mail"); mail_int.putExtra(Intent.EXTRA_BCC, ""); mail_int.putExtra(Intent.EXTRA_SUBJECT, " "); for (int i = 0; i < length; i++) { File file = new File(mMultiSelectData.get(i)); uris.add(Uri.fromFile(file)); } mail_int.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); mContext.startActivity(Intent.createChooser(mail_int, "Email using...")); mDelegate.killMultiSelect(true); break; case R.id.hidden_move: case R.id.hidden_copy: /* check if user selected objects before going further */ if (mMultiSelectData == null || mMultiSelectData.isEmpty()) { mDelegate.killMultiSelect(true); break; } if (v.getId() == R.id.hidden_move) delete_after_copy = true; mInfoLabel.setText("Holding " + mMultiSelectData.size() + " file(s)"); mDelegate.killMultiSelect(false); break; case R.id.hidden_delete: /* check if user selected objects before going further */ if (mMultiSelectData == null || mMultiSelectData.isEmpty()) { mDelegate.killMultiSelect(true); break; } final String[] data = new String[mMultiSelectData.size()]; int at = 0; for (String string : mMultiSelectData) data[at++] = string; AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage( "Are you sure you want to delete " + data.length + " files? This cannot be " + "undone."); builder.setCancelable(false); builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new BackgroundWork(DELETE_TYPE).execute(data); mDelegate.killMultiSelect(true); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mDelegate.killMultiSelect(true); dialog.cancel(); } }); builder.create().show(); break; } }
From source file:mp.paschalis.WatchBookActivity.java
/** * Creates a sharing {@link Intent}./*from w w w. j a v a 2s. c o m*/ * * @return The sharing intent. */ private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); String root = Environment.getExternalStorageDirectory() + ".SmartLib/Images"; new File(root).mkdirs(); File file = new File(root, app.selectedBook.isbn); try { FileOutputStream os = new FileOutputStream(file); bitmapBookCover.compress(CompressFormat.PNG, 80, os); os.flush(); os.close(); Uri uri = Uri.fromFile(file); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); } catch (Exception e) { Log.e(TAG, e.getStackTrace().toString()); } String bookInfo = "\n\n\n\n " + getString(R.string.bookInfo) + ":\n" + getString(R.string.title) + ": \t\t\t\t" + app.selectedBook.title + "\n" + getString(R.string.author) + ": \t\t\t" + app.selectedBook.authors + "\n" + getString(R.string.isbn) + ": \t\t\t\t" + app.selectedBook.isbn + "\n" + getString(R.string.published_) + " \t" + app.selectedBook.publishedYear + "\n" + getString(R.string.pages_) + " \t\t\t" + app.selectedBook.pageCount + "\n" + getString(R.string.isbn) + ": \t\t\t\t" + app.selectedBook.isbn + "\n" + getString(R.string.status) + ": \t\t\t" + App.getBookStatusString(app.selectedBook.status, WatchBookActivity.this) + "\n\n" + "http://books.google.com/books?vid=isbn" + app.selectedBook.isbn; shareIntent.putExtra(Intent.EXTRA_TEXT, bookInfo); return shareIntent; }
From source file:net.opendasharchive.openarchive.ReviewMediaActivity.java
private void showMedia() { if (mMedia.mimeType.startsWith("image")) { ArrayList<Uri> list = new ArrayList<>(); list.add(Uri.parse(mMedia.getOriginalFilePath())); new ImageViewer.Builder(this, list).setStartPosition(0).show(); } else {// ww w. jav a 2 s . c om Intent viewMediaIntent = new Intent(); viewMediaIntent.setAction(Intent.ACTION_VIEW); Uri uriFile = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", FileUtils.getFile(this, Uri.parse(mMedia.getOriginalFilePath()))); viewMediaIntent.setDataAndType(uriFile, mMedia.getMimeType()); viewMediaIntent.putExtra(Intent.EXTRA_STREAM, uriFile); viewMediaIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(viewMediaIntent); } }
From source file:com.achep.base.ui.fragments.dialogs.FeedbackDialog.java
private void attachLog(@NonNull Intent intent) { Context context = getActivity(); try {// w w w . j av a 2 s.c o m String log = Logcat.capture(); if (log == null) throw new Exception("Failed to capture the logcat."); // Prepare cache directory. File cacheDir = context.getCacheDir(); if (cacheDir == null) throw new Exception("Cache directory is inaccessible"); File directory = new File(cacheDir, LogsProviderBase.DIRECTORY); FileUtils.deleteRecursive(directory); // Clean-up cache folder if (!directory.mkdirs()) throw new Exception("Failed to create cache directory."); // Create log file. @SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); String fileName = "AcDisplay_log_" + sdf.format(new Date()) + ".txt"; File file = new File(directory, fileName); // Write to the file. if (!FileUtils.writeToFile(file, log)) throw new Exception("Failed to write log to the file."); // Put extra stream to the intent. Uri uri = Uri.parse("content://" + LogAttachmentProvider.AUTHORITY + "/" + fileName); intent.putExtra(Intent.EXTRA_STREAM, uri); } catch (Exception e) { String message = ResUtils.getString(getResources(), R.string.feedback_error_accessing_log, e.getMessage()); ToastUtils.showLong(context, message); } }
From source file:nuclei.ui.share.PackageTargetManager.java
protected void onSetFileProvider(Context context, String packageName, String authority, Intent intent) { if (mUri != null || mFile != null) { Uri uri = mUri;//from w w w . j a v a 2 s . co m String type = "*/*"; if (mFile != null) { uri = FileProvider.getUriForFile(context, authority, mFile); final int lastDot = mFile.getName().lastIndexOf('.'); if (lastDot >= 0) { String extension = mFile.getName().substring(lastDot + 1); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mimeType != null) type = mimeType; } } intent.setDataAndType(intent.getData(), type); intent.putExtra(Intent.EXTRA_STREAM, uri); if (packageName != null) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); } } else { intent.setType("text/plain"); } }
From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java
public static Intent createSendFileToAlfrescoIntent(FragmentActivity activity, File contentFile) { Intent i = new Intent(activity, PublicDispatcherActivity.class); i.setAction(Intent.ACTION_SEND);//from w ww .j ava2s .c o m i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(contentFile)); i.setType(MimeTypeManager.getInstance(activity).getMIMEType(contentFile.getName())); return i; }
From source file:com.heneryh.aquanotes.ui.livestock.ContentFragment.java
/** Share the currently selected photo using an AsyncTask to compress the image * and then invoke the appropriate share intent. *//*from w w w . j a v a 2s .co m*/ void shareCurrentPhoto() { File externalCacheDir = getActivity().getExternalCacheDir(); if (externalCacheDir == null) { Toast.makeText(getActivity(), "Error writing to USB/external storage.", Toast.LENGTH_SHORT).show(); return; } // Prevent media scanning of the cache directory. final File noMediaFile = new File(externalCacheDir, ".nomedia"); try { noMediaFile.createNewFile(); } catch (IOException e) { } // Write the bitmap to temporary storage in the external storage directory (e.g. SD card). // We perform the actual disk write operations on a separate thread using the // {@link AsyncTask} class, thus avoiding the possibility of stalling the main (UI) thread. final File tempFile = new File(externalCacheDir, "tempfile.jpg"); new AsyncTask<Void, Void, Boolean>() { /** * Compress and write the bitmap to disk on a separate thread. * @return TRUE if the write was successful, FALSE otherwise. */ @Override protected Boolean doInBackground(Void... voids) { try { FileOutputStream fo = new FileOutputStream(tempFile, false); if (!mBitmap.compress(Bitmap.CompressFormat.JPEG, 60, fo)) { Toast.makeText(getActivity(), "Error writing bitmap data.", Toast.LENGTH_SHORT).show(); return Boolean.FALSE; } return Boolean.TRUE; } catch (FileNotFoundException e) { Toast.makeText(getActivity(), "Error writing to USB/external storage.", Toast.LENGTH_SHORT) .show(); return Boolean.FALSE; } } /** * After doInBackground completes (either successfully or in failure), we invoke an * intent to share the photo. This code is run on the main (UI) thread. */ @Override protected void onPostExecute(Boolean result) { if (result != Boolean.TRUE) { return; } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tempFile)); shareIntent.setType("image/jpeg"); startActivity(Intent.createChooser(shareIntent, "Share photo")); } }.execute(); }
From source file:com.apotheosis.acceleration.monitor.MainMenuActivity.java
private void setUpListView() { ListView lv = (ListView) findViewById(R.id.fileList); List<String> fileNames = FileUtilities.getFileList(); if (fileNames != null) { FileListAdapter listAdapter = new FileListAdapter(this); lv.setAdapter(listAdapter);//from w ww . j a va2 s. c o m lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout.isDrawerOpen(findViewById(R.id.side_drawer)); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, parent.getAdapter().getItem(position).toString()).execute((Void[]) null); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final String fileName = parent.getAdapter().getItem(position).toString(); final AlertDialog.Builder optionsMenu = new AlertDialog.Builder(MainMenuActivity.this); optionsMenu.setItems(new String[] { "Open Acceleration Graph", "Open Raw Data", "Share Data", "Delete Data", "Cancel" }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout .isDrawerOpen(findViewById(R.id.side_drawer)); Intent i; Tracker tracker; switch (which) { case 0: dialog.dismiss(); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 1: if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.RAW_DATA, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 2: if (isDrawerOpen) drawerLayout.closeDrawers(); tracker = AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP); tracker.send(new HitBuilders.EventBuilder().setCategory("Data Function") .setAction("Share Data").build()); i = new Intent(Intent.ACTION_SEND); i.setType("text/xml"); i.putExtra(Intent.EXTRA_SUBJECT, "Sending " + fileName + "as attachment"); i.putExtra(Intent.EXTRA_TEXT, fileName + "is attached."); File f = new File(FileUtilities.path + fileName + ".csv"); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); startActivity(Intent.createChooser(i, "Choose an application...")); break; case 3: final AlertDialog.Builder confirmDelete = new AlertDialog.Builder( MainMenuActivity.this); confirmDelete .setMessage("Are you sure you want to delete " + fileName + "?"); confirmDelete.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { File f = new File(FileUtilities.path + fileName + ".csv"); Log.d("DELETION_SUCESS", String.valueOf(f.delete())); setUpListView(); } }); confirmDelete.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); confirmDelete.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); confirmDelete.show(); break; } } }); optionsMenu.show(); return true; } }); } }
From source file:com.stanleyidesis.quotograph.api.controller.LWQNotificationControllerImpl.java
@Override public void postSavedWallpaperReadyNotification(Uri filePath, Uri imageUri) { final Bitmap savedImage = BitmapFactory.decodeFile(filePath.getPath()); final Bitmap notificationBitmap = chopToCenterSquare(savedImage); savedImage.recycle();// w ww. j a v a2 s .c o m NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(LWQApplication.get()); notificationBuilder.setAutoCancel(true); notificationBuilder.setCategory(Notification.CATEGORY_SERVICE); notificationBuilder.setContentTitle(LWQApplication.get().getString(R.string.notification_title_save_image)); notificationBuilder .setContentText(LWQApplication.get().getString(R.string.notification_content_save_image)); notificationBuilder.setLights(LWQApplication.get().getResources().getColor(R.color.palette_A100), 500, 500); notificationBuilder.setLargeIcon(notificationBitmap); notificationBuilder.setOngoing(false); notificationBuilder.setShowWhen(false); notificationBuilder.setSmallIcon(R.mipmap.ic_stat); notificationBuilder.setTicker(LWQApplication.get().getString(R.string.notification_title_save_image)); notificationBuilder.setWhen(System.currentTimeMillis()); notificationBuilder.setColor(LWQApplication.get().getResources().getColor(R.color.palette_A100)); NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle(); bigPictureStyle.bigPicture(notificationBitmap); bigPictureStyle.bigLargeIcon(notificationBitmap); notificationBuilder.setStyle(bigPictureStyle); // Set content Intent final Intent viewIntent = new Intent(Intent.ACTION_VIEW); viewIntent.setDataAndType(imageUri, "image/*"); final Intent viewChooser = Intent.createChooser(viewIntent, LWQApplication.get().getString(R.string.view_using)); final PendingIntent viewActivity = PendingIntent.getActivity(LWQApplication.get(), uniqueRequestCode++, viewChooser, PendingIntent.FLAG_UPDATE_CURRENT); notificationBuilder.setContentIntent(viewActivity); // Add Share Action final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath.getPath()))); final Intent shareChooser = Intent.createChooser(shareIntent, LWQApplication.get().getString(R.string.share_using)); final PendingIntent shareActivity = PendingIntent.getActivity(LWQApplication.get(), uniqueRequestCode++, shareChooser, PendingIntent.FLAG_UPDATE_CURRENT); final NotificationCompat.Action shareAction = new NotificationCompat.Action.Builder(R.mipmap.ic_share_white, LWQApplication.get().getString(R.string.share), shareActivity).build(); notificationBuilder.addAction(shareAction); NotificationManager notificationManager = (NotificationManager) LWQApplication.get() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(savedImage.hashCode(), notificationBuilder.build()); notificationBitmap.recycle(); }
From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java
public void shareMsg(String activityTitle, String msgTitle, String msgText, String imgPath) { Intent intent = new Intent(Intent.ACTION_SEND); if (imgPath == null || imgPath.equals("")) { intent.setType("text/plain"); } else {/* w ww .ja v a2 s . c om*/ File f = new File(imgPath); if (f.exists() && f.isFile()) { intent.setType("image/jpg"); Uri uri = Uri.fromFile(f); intent.putExtra(Intent.EXTRA_STREAM, uri); } } intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle); intent.putExtra(Intent.EXTRA_TEXT, msgText); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, activityTitle)); }