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:name.zurell.kirk.apps.android.rhetolog.RhetologApplication.java
/** Called when a session detail view asks to send session results somewhere. * Generates a link to the session report Uri, and lets the remote program read from it. * The {@link RhetologContentProvider} generates the result file on demand. * /* ww w .java 2 s . c o m*/ * */ @Override public void onSessionSend(Context context, Uri session) { // Send to the program selected by the chooser below. Intent sendSession = new Intent(Intent.ACTION_SEND); // Permit to read from Rhetolog URIs. sendSession.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Note type of send as report. sendSession.setType(RhetologContract.RHETOLOG_TYPE_SESSION_REPORT); sendSession.putExtra(Intent.EXTRA_SUBJECT, "Sending session " + session); // Send text as text. sendSession.putExtra(Intent.EXTRA_TEXT, reportForSession(session)); // Send text as URI to be read. sendSession.putExtra(Intent.EXTRA_STREAM, Uri.parse(RhetologContract.SESSIONSREPORT + "/" + session.getLastPathSegment())); // Permit user to choose target of send. context.startActivity(Intent.createChooser(sendSession, "Send session results")); }
From source file:com.mEmoZz.qrgen.MainActivity.java
private void shareIt() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/png"); ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "title"); values.put(MediaStore.Images.Media.MIME_TYPE, "image/png"); Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); OutputStream outStream;/*from w w w. jav a 2 s.c o m*/ try { outStream = getContentResolver().openOutputStream(uri); bm.compress(Bitmap.CompressFormat.PNG, 100, outStream); outStream.close(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "I/O error", Toast.LENGTH_SHORT).show(); } shareIntent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(shareIntent, "Share Image")); }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); v = inflater.inflate(R.layout.dialog_backup, container, false); // get target translation to backup Bundle args = getArguments();/*from w ww. j av a 2 s . c o m*/ if (args != null && args.containsKey(ARG_TARGET_TRANSLATION_ID)) { String targetTranslationId = args.getString(ARG_TARGET_TRANSLATION_ID, null); targetTranslation = App.getTranslator().getTargetTranslation(targetTranslationId); if (targetTranslation == null) { throw new InvalidParameterException( "The target translation '" + targetTranslationId + "' is invalid"); } } else { throw new InvalidParameterException("The target translation id was not specified"); } targetTranslation.setDefaultContributor(App.getProfile().getNativeSpeaker()); mBackupToCloudButton = (LinearLayout) v.findViewById(R.id.backup_to_cloud); LinearLayout exportProjectButton = (LinearLayout) v.findViewById(R.id.backup_to_sd); Button backupToAppButton = (Button) v.findViewById(R.id.backup_to_app); Button backupToDeviceButton = (Button) v.findViewById(R.id.backup_to_device); LinearLayout exportToPDFButton = (LinearLayout) v.findViewById(R.id.export_to_pdf); LinearLayout exportToUsfmButton = (LinearLayout) v.findViewById(R.id.export_to_usfm); Button logout = (Button) v.findViewById(R.id.logout_button); logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { App.setProfile(null); Intent logoutIntent = new Intent(getActivity(), ProfileActivity.class); startActivity(logoutIntent); } }); final String filename = targetTranslation.getId() + "." + Translator.ARCHIVE_EXTENSION; initProgressWatcher(R.string.backup); if (savedInstanceState != null) { // check if returning from device alias dialog settingDeviceAlias = savedInstanceState.getBoolean(STATE_SETTING_DEVICE_ALIAS, false); mDialogShown = eDialogShown .fromInt(savedInstanceState.getInt(STATE_DIALOG_SHOWN, eDialogShown.NONE.getValue())); mAccessFile = savedInstanceState.getString(STATE_ACCESS_FILE, null); mDialogMessage = savedInstanceState.getString(STATE_DIALOG_MESSAGE, null); isOutputToDocumentFile = savedInstanceState.getBoolean(STATE_OUTPUT_TO_DOCUMENT_FILE, false); mDestinationFolderUri = Uri.parse(savedInstanceState.getString(STATE_OUTPUT_FOLDER_URI, "")); restoreDialogs(); } Button dismissButton = (Button) v.findViewById(R.id.dismiss_button); dismissButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); backupToDeviceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: 11/18/2015 eventually we need to support bluetooth as well as an adhoc network showDeviceNetworkAliasDialog(); } }); // backup buttons mBackupToCloudButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (App.isNetworkAvailable()) { // make sure we have a gogs user if (App.getProfile().gogsUser == null) { showDoor43LoginDialog(); return; } doPullTargetTranslationTask(targetTranslation, MergeStrategy.RECURSIVE); } else { showNoInternetDialog(); // replaced snack popup which could be hidden behind dialog } } }); exportToPDFButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PrintDialog printDialog = new PrintDialog(); Bundle printArgs = new Bundle(); printArgs.putString(PrintDialog.ARG_TARGET_TRANSLATION_ID, targetTranslation.getId()); printDialog.setArguments(printArgs); showDialogFragment(printDialog, PrintDialog.TAG); } }); exportProjectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doSelectDestinationFolder(false); } }); exportToUsfmButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doSelectDestinationFolder(true); } }); if (targetTranslation.isObsProject()) { LinearLayout exportToUsfmSeparator = (LinearLayout) v.findViewById(R.id.export_to_usfm_separator); exportToUsfmSeparator.setVisibility(View.GONE); exportToUsfmButton.setVisibility(View.GONE); } backupToAppButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File exportFile = new File(App.getSharingDir(), filename); try { App.getTranslator().exportArchive(targetTranslation, exportFile); } catch (Exception e) { Logger.e(TAG, "Failed to export the target translation " + targetTranslation.getId(), e); } if (exportFile.exists()) { Uri u = FileProvider.getUriForFile(getActivity(), "com.door43.translationstudio.fileprovider", exportFile); Intent i = new Intent(Intent.ACTION_SEND); i.setType("application/zip"); i.putExtra(Intent.EXTRA_STREAM, u); startActivity(Intent.createChooser(i, "Email:")); } else { Snackbar snack = Snackbar.make(getActivity().findViewById(android.R.id.content), R.string.translation_export_failed, Snackbar.LENGTH_LONG); ViewUtil.setSnackBarTextColor(snack, getResources().getColor(R.color.light_primary_text)); snack.show(); } } }); // connect to existing tasks PullTargetTranslationTask pullTask = (PullTargetTranslationTask) TaskManager .getTask(PullTargetTranslationTask.TASK_ID); RegisterSSHKeysTask keysTask = (RegisterSSHKeysTask) TaskManager.getTask(RegisterSSHKeysTask.TASK_ID); CreateRepositoryTask repoTask = (CreateRepositoryTask) TaskManager.getTask(CreateRepositoryTask.TASK_ID); PushTargetTranslationTask pushTask = (PushTargetTranslationTask) TaskManager .getTask(PushTargetTranslationTask.TASK_ID); ExportProjectTask projectExportTask = (ExportProjectTask) TaskManager.getTask(ExportProjectTask.TASK_ID); ExportToUsfmTask usfmExportTask = (ExportToUsfmTask) TaskManager.getTask(ExportToUsfmTask.TASK_ID); if (pullTask != null) { taskWatcher.watch(pullTask); } else if (keysTask != null) { taskWatcher.watch(keysTask); } else if (repoTask != null) { taskWatcher.watch(repoTask); } else if (pushTask != null) { taskWatcher.watch(pushTask); } else if (projectExportTask != null) { taskWatcher.watch(projectExportTask); } else if (usfmExportTask != null) { taskWatcher.watch(usfmExportTask); } return v; }
From source file:com.tweetlanes.android.core.view.HomeActivity.java
void onCreateHandleIntents() { boolean turnSoftKeyboardOff = true; Intent intent = getIntent();/* w ww.ja v a2 s.co m*/ Bundle extras = intent.getExtras(); if (extras != null) { String type = intent.getType(); if (intent.getAction() == Intent.ACTION_SEND && type != null) { if (type.equals("text/plain") && extras.containsKey(Intent.EXTRA_TEXT)) { String shareString = extras.getString(Intent.EXTRA_TEXT); if (extras.containsKey(Intent.EXTRA_SUBJECT)) { shareString = extras.getString(Intent.EXTRA_SUBJECT) + " " + shareString; } beginShareStatus(shareString); turnSoftKeyboardOff = false; } else if (type.contains("image/")) { // From http://stackoverflow.com/a/2641363/328679 if (extras.containsKey(Intent.EXTRA_STREAM)) { Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); String scheme = uri.getScheme(); if (scheme.equals("content")) { ContentResolver contentResolver = getContentResolver(); Cursor cursor = contentResolver.query(uri, null, null, null, null); cursor.moveToFirst(); try { String imagePath = cursor .getString(cursor.getColumnIndexOrThrow(Images.Media.DATA)); beginShareImage(imagePath); } catch (java.lang.IllegalArgumentException e) { Toast.makeText(this, R.string.picture_attach_error, Toast.LENGTH_SHORT).show(); } finally { cursor.close(); cursor = null; } turnSoftKeyboardOff = false; } } } } } if (turnSoftKeyboardOff) { // Turn the soft-keyboard off. For some reason it wants to appear on // screen by default when coming back from multitasking... getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); } }
From source file:nuclei.ui.share.PackageTargetManager.java
/** * WeChat and on some android versions Instagram doesn't seem to handle file providers very well, so instead of those we move the * file to external storage and startActivityForResult with the actual file. *//*from w w w. j a va 2s. c om*/ protected Intent onExternalStorage(Activity activity, String packageName, String authority, Intent intent, int permissionRequestCode, boolean stripText) { if (mFile != null) { if (ContextCompat.checkSelfPermission(activity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { File file = ShareUtil.newShareFile(new File(Environment.getExternalStorageDirectory(), ".cyto"), mFile.getName()); try { onCopyFile(mFile, file); mFile.delete(); mFile = file; } catch (IOException err) { LOG.e("Error copying file for sharing", err); } onSetFileProvider(activity, packageName, authority, intent); } else { File file = ShareUtil.newShareFile(new File(Environment.getExternalStorageDirectory(), ".cyto"), mFile.getName()); try { onCopyFile(mFile, file); mFile.delete(); mFile = file; } catch (IOException err) { LOG.e("Error copying file for sharing", err); } intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mFile)); } } else { ActivityCompat.requestPermissions(activity, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, permissionRequestCode); return null; } if (stripText && intent.hasExtra(Intent.EXTRA_STREAM) && intent.hasExtra(Intent.EXTRA_TEXT)) intent.removeExtra(Intent.EXTRA_TEXT); } return intent; }
From source file:org.alfresco.mobile.android.application.manager.ActionManager.java
public static boolean actionSendMailWithAttachment(Fragment fr, String subject, String content, Uri attachment, int requestCode) { try {//from w w w .j a v a 2 s . co m Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(content)); i.putExtra(Intent.EXTRA_STREAM, attachment); i.setType("text/plain"); fr.startActivityForResult(Intent.createChooser(i, fr.getString(R.string.send_email)), requestCode); return true; } catch (Exception e) { MessengerManager.showToast(fr.getActivity(), R.string.decryption_failed); Log.d(TAG, Log.getStackTraceString(e)); } return false; }
From source file:com.microsoft.mimickeralarm.ringing.ShareFragment.java
public void share() { Loggable.UserAction userAction = new Loggable.UserAction(Loggable.Key.ACTION_SHARE); Logger.track(userAction);// w w w . jav a 2s .c om mCallback.onRequestLaunchShareAction(); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); // this causes issues with gmail //shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); File file = new File(mShareableUri); Uri uri = Uri.fromFile(file); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_text_template)); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.share_subject_template)); shareIntent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivityForResult( Intent.createChooser(shareIntent, getResources().getString(R.string.share_action_description)), SHARE_REQUEST_CODE); }
From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java
public static Intent createSendIntent(FragmentActivity activity, File contentFile) { Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_SUBJECT, contentFile.getName()); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(contentFile)); i.setType(MimeTypeManager.getInstance(activity).getMIMEType(contentFile.getName())); return i;//from w w w.j ava2s.com }
From source file:com.mbientlab.metawear.app.SensorFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); chart = (LineChart) view.findViewById(R.id.data_chart); initializeChart();// ww w.jav a 2 s . co m resetData(false); chart.invalidate(); view.findViewById(R.id.data_clear).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { chart.resetTracking(); chart.clear(); resetData(true); chart.invalidate(); } }); ((Switch) view.findViewById(R.id.sample_control)) .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { moveViewToLast(); setup(); chartHandler.postDelayed(updateChartTask, UPDATE_PERIOD); } else { chart.setVisibleXRangeMaximum(sampleCount); clean(); if (streamRouteManager != null) { streamRouteManager.remove(); streamRouteManager = null; } chartHandler.removeCallbacks(updateChartTask); } } }); view.findViewById(R.id.data_save).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String filename = saveData(); if (filename != null) { File dataFile = getActivity().getFileStreamPath(filename); Uri contentUri = FileProvider.getUriForFile(getActivity(), "com.mbientlab.metawear.app.fileprovider", dataFile); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, filename); intent.putExtra(Intent.EXTRA_STREAM, contentUri); startActivity(Intent.createChooser(intent, "Saving Data")); } } }); }
From source file:im.vector.fragments.ConsoleMessageListFragment.java
/** * User actions when the user click on message row. * This example displays a menu to perform some actions on the message. *//*from ww w . j a va 2s .c om*/ @Override public void onItemClick(int position) { final MessageRow messageRow = mAdapter.getItem(position); final List<Integer> textIds = new ArrayList<>(); final List<Integer> iconIds = new ArrayList<Integer>(); String mediaUrl = null; String mediaMimeType = null; Uri mediaUri = null; Message message = JsonUtils.toMessage(messageRow.getEvent().content); if (!Event.EVENT_TYPE_STATE_ROOM_TOPIC.equals(messageRow.getEvent().type) && !Event.EVENT_TYPE_STATE_ROOM_MEMBER.equals(messageRow.getEvent().type) && !Event.EVENT_TYPE_STATE_ROOM_NAME.equals(messageRow.getEvent().type)) { if (messageRow.getEvent().canBeResent()) { textIds.add(R.string.resend); iconIds.add(R.drawable.ic_material_send); } else if (messageRow.getEvent().mSentState == Event.SentState.SENT) { textIds.add(R.string.redact); iconIds.add(R.drawable.ic_material_clear); if (Event.EVENT_TYPE_MESSAGE.equals(messageRow.getEvent().type)) { Boolean supportShare = true; // check if the media has been downloaded if ((message instanceof ImageMessage) || (message instanceof FileMessage)) { if (message instanceof ImageMessage) { ImageMessage imageMessage = (ImageMessage) message; mediaUrl = imageMessage.url; mediaMimeType = imageMessage.getMimeType(); } else { FileMessage fileMessage = (FileMessage) message; mediaUrl = fileMessage.url; mediaMimeType = fileMessage.getMimeType(); } supportShare = false; MXMediasCache cache = getMXMediasCache(); File mediaFile = cache.mediaCacheFile(mediaUrl, mediaMimeType); if (null != mediaFile) { try { mediaUri = ConsoleContentProvider.absolutePathToUri(getActivity(), mediaFile.getAbsolutePath()); supportShare = true; } catch (Exception e) { } } } if (supportShare) { textIds.add(R.string.share); iconIds.add(R.drawable.ic_material_share); textIds.add(R.string.forward); iconIds.add(R.drawable.ic_material_forward); textIds.add(R.string.save); iconIds.add(R.drawable.ic_material_save); } } } } // display the JSON textIds.add(R.string.message_details); iconIds.add(R.drawable.ic_material_description); FragmentManager fm = getActivity().getSupportFragmentManager(); IconAndTextDialogFragment fragment = (IconAndTextDialogFragment) fm .findFragmentByTag(TAG_FRAGMENT_MESSAGE_OPTIONS); if (fragment != null) { fragment.dismissAllowingStateLoss(); } Integer[] lIcons = iconIds.toArray(new Integer[iconIds.size()]); Integer[] lTexts = textIds.toArray(new Integer[iconIds.size()]); final String fmediaMimeType = mediaMimeType; final Uri fmediaUri = mediaUri; final String fmediaUrl = mediaUrl; final Message fMessage = message; fragment = IconAndTextDialogFragment.newInstance(lIcons, lTexts); fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener() { @Override public void onItemClick(IconAndTextDialogFragment dialogFragment, int position) { final Integer selectedVal = textIds.get(position); if (selectedVal == R.string.resend) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { resend(messageRow.getEvent()); } }); } else if (selectedVal == R.string.save) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { save(fMessage, fmediaUrl, fmediaMimeType); } }); } else if (selectedVal == R.string.redact) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { redactEvent(messageRow.getEvent().eventId); } }); } else if ((selectedVal == R.string.share) || (selectedVal == R.string.forward)) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); Event event = messageRow.getEvent(); Message message = JsonUtils.toMessage(event.content); if (null != fmediaUri) { sendIntent.setType(fmediaMimeType); sendIntent.putExtra(Intent.EXTRA_STREAM, fmediaUri); } else { sendIntent.putExtra(Intent.EXTRA_TEXT, message.body); sendIntent.setType("text/plain"); } if (selectedVal == R.string.forward) { CommonActivityUtils.sendFilesTo(getActivity(), sendIntent); } else { startActivity(sendIntent); } } }); } else if (selectedVal == R.string.message_details) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { FragmentManager fm = getActivity().getSupportFragmentManager(); MessageDetailsFragment fragment = (MessageDetailsFragment) fm .findFragmentByTag(TAG_FRAGMENT_MESSAGE_DETAILS); if (fragment != null) { fragment.dismissAllowingStateLoss(); } fragment = MessageDetailsFragment.newInstance(messageRow.getEvent().toString()); fragment.show(fm, TAG_FRAGMENT_MESSAGE_DETAILS); } }); } } }); fragment.show(fm, TAG_FRAGMENT_MESSAGE_OPTIONS); }