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.waz.zclient.controllers.notifications.NotificationsController.java
private PendingIntent getGalleryIntent(Uri uri) { // TODO: AN-2276 - Replace with ShareCompat.IntentBuilder Intent galleryIntent = new Intent(Intent.ACTION_VIEW); galleryIntent.setDataAndTypeAndNormalize(uri, "image/*"); galleryIntent.setClipData(new ClipData(null, new String[] { "image/*" }, new ClipData.Item(uri))); galleryIntent.putExtra(Intent.EXTRA_STREAM, uri); return PendingIntent.getActivity(context, 0, galleryIntent, 0); }
From source file:com.rockacode.ocr.ui.camera.CameraFragment.java
private void startImageDetails(String file) { Intent intent = new Intent(getActivity(), ImageActivity.class); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mFile)); startActivity(intent);/* w w w . j av a 2 s . c om*/ }
From source file:com.waz.zclient.controllers.notifications.NotificationsController.java
private PendingIntent getPendingShareIntent(Uri uri) { Intent shareIntent = new Intent(context, ShareSavedImageActivity.class); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(IntentUtils.EXTRA_LAUNCH_FROM_SAVE_IMAGE_NOTIFICATION, true); return PendingIntent.getActivity(context, 0, shareIntent, 0); }
From source file:com.geotrackin.gpslogger.GpsMainActivity.java
/** * Allows user to send a GPX/KML file along with location, or location only * using a provider. 'Provider' means any application that can accept such * an intent (Facebook, SMS, Twitter, Email, K-9, Bluetooth) *//*from w w w . j a va2 s . c o m*/ private void Share() { tracer.debug("GpsMainActivity.Share"); try { final String locationOnly = getString(R.string.sharing_location_only); final File gpxFolder = new File(AppSettings.getGpsLoggerFolder()); if (gpxFolder.exists()) { File[] enumeratedFiles = Utilities.GetFilesInFolder(gpxFolder); Arrays.sort(enumeratedFiles, new Comparator<File>() { public int compare(File f1, File f2) { return -1 * Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); } }); List<String> fileList = new ArrayList<String>(enumeratedFiles.length); for (File f : enumeratedFiles) { fileList.add(f.getName()); } fileList.add(0, locationOnly); final String[] files = fileList.toArray(new String[fileList.size()]); final ArrayList selectedItems = new ArrayList(); // Where we track the selected items AlertDialog.Builder builder = new AlertDialog.Builder(this); // Set the dialog title builder.setTitle(R.string.osm_pick_file) .setMultiChoiceItems(files, null, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { if (which == 0) { //Unselect all others ((AlertDialog) dialog).getListView().clearChoices(); ((AlertDialog) dialog).getListView().setItemChecked(which, isChecked); selectedItems.clear(); } else { //Unselect the settings item ((AlertDialog) dialog).getListView().setItemChecked(0, false); if (selectedItems.contains(0)) { selectedItems.remove(selectedItems.indexOf(0)); } } selectedItems.add(which); } else if (selectedItems.contains(which)) { // Else, if the item is already in the array, remove it selectedItems.remove(Integer.valueOf(which)); } } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (selectedItems.size() <= 0) { return; } final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("*/*"); if (selectedItems.get(0).equals(0)) { tracer.debug("User selected location only"); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.sharing_mylocation)); if (Session.hasValidLocation()) { String bodyText = getString(R.string.sharing_googlemaps_link, String.valueOf(Session.getCurrentLatitude()), String.valueOf(Session.getCurrentLongitude())); intent.putExtra(Intent.EXTRA_TEXT, bodyText); intent.putExtra("sms_body", bodyText); startActivity( Intent.createChooser(intent, getString(R.string.sharing_via))); } } else { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_SUBJECT, "Geotrackin (Android app): Here are some files."); intent.setType("*/*"); ArrayList<Uri> chosenFiles = new ArrayList<Uri>(); for (Object path : selectedItems) { File file = new File(gpxFolder, files[Integer.valueOf(path.toString())]); Uri uri = Uri.fromFile(file); chosenFiles.add(uri); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, chosenFiles); startActivity(Intent.createChooser(intent, getString(R.string.sharing_via))); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { selectedItems.clear(); } }); builder.create(); builder.show(); } else { Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this); } } catch (Exception ex) { tracer.error("Share", ex); } }
From source file:com.irccloud.android.activity.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_logout: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Logout"); builder.setMessage("Would you like to logout of IRCCloud?"); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override/* ww w . j a v a2 s. c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Logout", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); conn.logout(); if (mGoogleApiClient.isConnected()) { Auth.CredentialsApi.disableAutoSignIn(mGoogleApiClient) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } }); } else { Intent i = new Intent(BaseActivity.this, LoginActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); finish(); } } }); AlertDialog dialog = builder.create(); dialog.setOwnerActivity(this); dialog.show(); break; case R.id.menu_settings: Intent i = new Intent(this, PreferencesActivity.class); startActivity(i); break; case R.id.menu_feedback: try { String bugReport = "Briefly describe the issue below:\n\n\n\n\n" + "===========\n" + ((NetworkConnection.getInstance().getUserInfo() != null) ? ("UID: " + NetworkConnection.getInstance().getUserInfo().id + "\n") : "") + "App version: " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " (" + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + ")\n" + "Device: " + Build.MODEL + "\n" + "Android version: " + Build.VERSION.RELEASE + "\n" + "Firmware fingerprint: " + Build.FINGERPRINT + "\n"; File logsDir = new File(getFilesDir(), ".Fabric/com.crashlytics.sdk.android.crashlytics-core/log-files/"); File log = null; File output = null; if (logsDir.exists()) { long max = Long.MIN_VALUE; for (File f : logsDir.listFiles()) { if (f.lastModified() > max) { max = f.lastModified(); log = f; } } if (log != null) { File f = new File(getFilesDir(), "logs"); f.mkdirs(); output = new File(f, LOG_FILENAME); byte[] b = new byte[1]; FileOutputStream out = new FileOutputStream(output); FileInputStream is = new FileInputStream(log); is.skip(5); while (is.available() > 0 && is.read(b, 0, 1) > 0) { if (b[0] == ' ') { while (is.available() > 0 && is.read(b, 0, 1) > 0) { out.write(b); if (b[0] == '\n') break; } } } is.close(); out.close(); } } Intent email = new Intent(Intent.ACTION_SEND); email.setData(Uri.parse("mailto:")); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "IRCCloud Team <team@irccloud.com>" }); email.putExtra(Intent.EXTRA_TEXT, bugReport); email.putExtra(Intent.EXTRA_SUBJECT, "IRCCloud for Android"); if (log != null) { email.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", output)); } startActivityForResult(Intent.createChooser(email, "Send Feedback:"), 0); } catch (Exception e) { Toast.makeText(this, "Unable to generate email report: " + e.getMessage(), Toast.LENGTH_SHORT) .show(); Crashlytics.logException(e); NetworkConnection.printStackTraceToCrashlytics(e); } break; } return super.onOptionsItemSelected(item); }
From source file:com.mjhram.geodata.GpsMainActivity.java
public void captureAndShareGMap() { GoogleMap.SnapshotReadyCallback callback = new GoogleMap.SnapshotReadyCallback() { @Override/*from w w w .j a va2 s . c o m*/ public void onSnapshotReady(Bitmap snapshot1) { // TODO Auto-generated method stub SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastMarkerTime); String eTime = sdf.format(calendar.getTime()); calendar.setTimeInMillis(firstMarkerTime); String fTime = sdf.format(calendar.getTime()); sdf.applyPattern("dd MMM,yyyy"); String fDate = sdf.format(calendar.getTime()); String dateString = fDate + " " + fTime + "-" + eTime; Bitmap snapshot = drawMultilineTextToBitmap(GpsMainActivity.this, snapshot1, dateString); //bitmap = snapshot; String filePath = System.currentTimeMillis() + ".jpeg"; File folder = new File(Environment.getExternalStorageDirectory() + "/geodatatmp"); boolean success = true; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { return; } //filePath = Environment.getExternalStorageDirectory().toString() + "/" + filePath; try { File imageFile = new File(folder, filePath); FileOutputStream fout = new FileOutputStream(imageFile); // Write the string to the file snapshot.compress(Bitmap.CompressFormat.JPEG, 90, fout); fout.flush(); fout.close(); //Toast.makeText(GpsMainActivity.this, "Stored in: " + filePath, Toast.LENGTH_LONG).show(); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imageFile)); shareIntent.setType("image/jpeg"); startActivity(Intent.createChooser(shareIntent, "Sahre...")); } catch (FileNotFoundException e) { // TODO Auto-generated catch block Log.d("ImageCapture", "FileNotFoundException"); Log.d("ImageCapture", e.getMessage()); filePath = ""; } catch (IOException e) { // TODO Auto-generated catch block Log.d("ImageCapture", "IOException"); Log.d("ImageCapture", e.getMessage()); filePath = ""; } //openShareImageDialog(filePath); } }; googleMap.snapshot(callback); }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case RequestCode.FILEPICKER: if (data != null && PrivateIntent.ACTION_PICK_FILE.equals(data.getAction())) { ActionUtils.actionPickFile(getFragmentManager().findFragmentByTag(TAG), RequestCode.FILEPICKER); } else if (data != null && data.getData() != null) { String tmpPath = ActionUtils.getPath(getActivity(), data.getData()); if (tmpPath != null) { tmpFile = new File(tmpPath); } else { // Error case : Unable to find the file path associated // to user pick. // Sample : Picasa image case ActionUtils.actionDisplayError(this, new AlfrescoAppException(getString(R.string.error_unknown_filepath), true)); }//w w w. j a v a 2s.c o m } else if (data != null && data.getExtras() != null && data.getExtras().containsKey(Intent.EXTRA_STREAM)) { List<File> files = new ArrayList<File>(); List<Uri> uris = data.getExtras().getParcelableArrayList(Intent.EXTRA_STREAM); for (Uri uri : uris) { files.add(new File(ActionUtils.getPath(getActivity(), uri))); } createFiles(files); } break; default: break; } }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
private boolean handleDefaultIntent(final Intent intent) { if (intent == null) return false; final String action = intent.getAction(); mShouldSaveAccounts = !Intent.ACTION_SEND.equals(action) && !Intent.ACTION_SEND_MULTIPLE.equals(action); final Uri data = intent.getData(); final CharSequence extraSubject = intent.getCharSequenceExtra(Intent.EXTRA_SUBJECT); final CharSequence extraText = intent.getCharSequenceExtra(Intent.EXTRA_TEXT); final Uri extraStream = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (extraStream != null) { new AddMediaTask(this, extraStream, createTempImageUri(), ParcelableMedia.TYPE_IMAGE, false).execute(); } else if (data != null) { new AddMediaTask(this, data, createTempImageUri(), ParcelableMedia.TYPE_IMAGE, false).execute(); } else if (intent.hasExtra(EXTRA_SHARE_SCREENSHOT)) { final Bitmap bitmap = intent.getParcelableExtra(EXTRA_SHARE_SCREENSHOT); if (bitmap != null) { try { new AddBitmapTask(this, bitmap, createTempImageUri(), ParcelableMedia.TYPE_IMAGE).execute(); } catch (IOException e) { // ignore bitmap.recycle();// w w w . j a v a2 s. com } } } mEditText.setText(getShareStatus(this, extraSubject, extraText)); final int selection_end = mEditText.length(); mEditText.setSelection(selection_end); return true; }
From source file:de.enlightened.peris.PerisMain.java
final void handleSendImage(final Intent intent) { final Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); /*//from w w w . j a v a 2 s. co m if (imageUri != null) { // Update UI to reflect image being shared }*/ }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void emailLog(final CallbackContext callback, final String email) { cordova.getThreadPool().execute(new Runnable() { public void run() { String log = readLog(); if (log == null) { callback.error(500);// w w w . ja v a 2 s. co m return; } Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("message/rfc822"); mailer.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); mailer.putExtra(Intent.EXTRA_SUBJECT, "BackgroundGeolocation log"); try { JSONObject state = getState(); if (state.has("license")) { state.put("license", "<SECRET>"); } if (state.has("orderId")) { state.put("orderId", "<SECRET>"); } mailer.putExtra(Intent.EXTRA_TEXT, state.toString(4)); } catch (JSONException e) { Log.w(TAG, "- Failed to write state to email body"); e.printStackTrace(); } File file = new File(Environment.getExternalStorageDirectory(), "background-geolocation.log"); try { FileOutputStream stream = new FileOutputStream(file); try { stream.write(log.getBytes()); stream.close(); mailer.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); file.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { Log.i(TAG, "FileNotFound"); e.printStackTrace(); } try { cordova.getActivity() .startActivityForResult(Intent.createChooser(mailer, "Send log: " + email + "..."), 1); callback.success(); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(cordova.getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show(); callback.error("There are no email clients installed"); } } }); }