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.nikhilnayak.games.octoshootar.ui.fragments.GameScoreFragment.java
private void handleShareScore() { new AsyncTask<Void, Void, Uri>() { @Override//from www . j a v a2 s .c om protected Uri doInBackground(Void... params) { final Bitmap bitmapToShare = getBitmapToShare(); //Compress the bitmap before saving and sharing. ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmapToShare.compress(Bitmap.CompressFormat.JPEG, BITMAP_QUALITY, bytes); bitmapToShare.recycle(); final Uri uriToShare = writeScoreBytesToExternalStorage(bytes); return uriToShare; } @Override protected void onPostExecute(Uri uri) { super.onPostExecute(uri); if (uri != null) { // Add the screen to the Media Provider's database. Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri); getActivity().sendBroadcast(mediaScanIntent); // Share intent Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); getActivity().startActivity(shareIntent); } } }.execute(); }
From source file:cn.ucai.wechat.ui.SettingsActivity.java
void sendLogThroughMail() { String logPath = ""; try {/*from ww w.j ava 2 s . c o m*/ logPath = EMClient.getInstance().compressLogs(); } catch (Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(SettingsActivity.this, "compress logs failed", Toast.LENGTH_LONG).show(); } }); return; } File f = new File(logPath); File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); if (f.exists() && f.canRead()) { try { storage.mkdirs(); File temp = File.createTempFile("hyphenate", ".log.gz", storage); if (!temp.canWrite()) { return; } boolean result = f.renameTo(temp); if (result == false) { return; } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_SUBJECT, "log"); intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath()); intent.setType("application/octet-stream"); ArrayList<Uri> uris = new ArrayList<>(); uris.add(Uri.fromFile(temp)); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(intent); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(SettingsActivity.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }); } } }
From source file:im.vector.fragments.VectorMessageListFragment.java
/*** * Manage save / share / forward actions on a media file * @param menuAction the menu action ACTION_VECTOR__XXX * @param mediaUrl the media URL (must be not null) * @param mediaMimeType the mime type// ww w. j a v a 2 s . co m * @param filename the filename */ protected void onMediaAction(final int menuAction, final String mediaUrl, final String mediaMimeType, final String filename) { MXMediasCache mediasCache = Matrix.getInstance(getActivity()).getMediasCache(); File file = mediasCache.mediaCacheFile(mediaUrl, mediaMimeType); // check if the media has already been downloaded if (null != file) { // download if ((menuAction == ACTION_VECTOR_SAVE) || (menuAction == ACTION_VECTOR_OPEN)) { String savedMediaPath = CommonActivityUtils.saveMediaIntoDownloads(getActivity(), file, filename, mediaMimeType); if (null != savedMediaPath) { if (menuAction == ACTION_VECTOR_SAVE) { Toast.makeText(getActivity(), getText(R.string.media_slider_saved), Toast.LENGTH_LONG) .show(); } else { CommonActivityUtils.openMedia(getActivity(), savedMediaPath, mediaMimeType); } } } else { // shared / forward Uri mediaUri = null; File renamedFile = file; if (!TextUtils.isEmpty(filename)) { try { InputStream fin = new FileInputStream(file); String tmpUrl = mediasCache.saveMedia(fin, filename, mediaMimeType); if (null != tmpUrl) { renamedFile = mediasCache.mediaCacheFile(tmpUrl, mediaMimeType); } } catch (Exception e) { Log.e(LOG_TAG, "onMediaAction shared / forward failed : " + e.getLocalizedMessage()); } } if (null != renamedFile) { try { mediaUri = VectorContentProvider.absolutePathToUri(getActivity(), renamedFile.getAbsolutePath()); } catch (Exception e) { Log.e(LOG_TAG, "onMediaAction VectorContentProvider.absolutePathToUri: " + e.getLocalizedMessage()); } } if (null != mediaUri) { final Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType(mediaMimeType); sendIntent.putExtra(Intent.EXTRA_STREAM, mediaUri); if (menuAction == ACTION_VECTOR_FORWARD) { CommonActivityUtils.sendFilesTo(getActivity(), sendIntent); } else { startActivity(sendIntent); } } } } else { // else download it final String downloadId = mediasCache.downloadMedia(getActivity(), mSession.getHomeserverConfig(), mediaUrl, mediaMimeType); mAdapter.notifyDataSetChanged(); if (null != downloadId) { mediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() { @Override public void onDownloadError(String downloadId, JsonElement jsonElement) { MatrixError error = JsonUtils.toMatrixError(jsonElement); if ((null != error) && error.isSupportedErrorCode()) { Toast.makeText(VectorMessageListFragment.this.getActivity(), error.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(downloadId)) { VectorMessageListFragment.this.getActivity().runOnUiThread(new Runnable() { @Override public void run() { onMediaAction(menuAction, mediaUrl, mediaMimeType, filename); } }); } } }); } } }
From source file:nl.mpcjanssen.simpletask.Simpletask.java
private void shareText(String text) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Simpletask list"); // If text is small enough SEND it directly if (text.length() < 50000) { shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, text); } else {/* w w w . ja v a 2s .com*/ // Create a cache file to pass in EXTRA_STREAM try { Util.createCachedFile(this, Constants.SHARE_FILE_NAME, text); Uri fileUri = Uri .parse("content://" + CachedFileProvider.AUTHORITY + "/" + Constants.SHARE_FILE_NAME); shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, fileUri); } catch (Exception e) { Log.w(TAG, "Failed to create file for sharing"); } } startActivity(Intent.createChooser(shareIntent, "Share")); }
From source file:com.kevin.cattalk.ui.SettingsFragment.java
void sendLogThroughMail() { String logPath = ""; try {//www.ja v a 2 s. c o m logPath = EMClient.getInstance().compressLogs(); } catch (Exception e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), "compress logs failed", Toast.LENGTH_LONG).show(); } }); return; } File f = new File(logPath); File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); if (f.exists() && f.canRead()) { try { storage.mkdirs(); File temp = File.createTempFile("hyphenate", ".log.gz", storage); if (!temp.canWrite()) { return; } boolean result = f.renameTo(temp); if (result == false) { return; } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_SUBJECT, "log"); intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath()); intent.setType("application/octet-stream"); ArrayList<Uri> uris = new ArrayList<>(); uris.add(Uri.fromFile(temp)); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(intent); } catch (final Exception e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getContext(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }); } } }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTweetingsApplication().getServiceInterface(); mResolver = getContentResolver();/* w w w .j a v a 2 s. c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.compose); mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1; mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null; mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1; mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null; mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null; mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null; mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false; mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false; mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null; final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null; final String account_username = getAccountUsername(this, account_id); int text_selection_start = -1; mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false; if (mInReplyToStatusId > 0) { if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null && (mentions == null || mentions.length < 1)) { mText = bundle.getString(INTENT_KEY_TEXT); } else if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); text_selection_start = mText.indexOf(' ') + 1; } mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false; final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String name = display_name ? mInReplyToName : mInReplyToScreenName; if (name != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } TextView replyText = (TextView) findViewById(R.id.reply_text); if (!isNullOrEmpty(mInReplyToText)) { replyText.setVisibility(View.VISIBLE); replyText.setText(mInReplyToText); } else { replyText.setVisibility(View.GONE); } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); } if (mAccountIds == null || mAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ','); final long[] activated_ids = getActivatedAccountIds(this); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids); mAccountIds = intersection.length > 0 ? intersection : activated_ids; } final String action = getIntent().getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { setTitle(R.string.share); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (mText == null) { final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT); final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT); mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text)); } else { mText = bundle.getString(INTENT_KEY_TEXT); } if (mImageUri == null) { final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM); final String content_type = getIntent().getType(); if (extra_stream != null && content_type != null && content_type.startsWith("image/")) { final String real_path = getImagePathFromUri(this, extra_stream); final File file = real_path != null ? new File(real_path) : null; if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsImageAttached = true; mIsPhotoAttached = false; } else { mImageUri = null; mIsImageAttached = false; } } } } } else if (bundle != null) { if (bundle.getString(INTENT_KEY_TEXT) != null) { mText = bundle.getString(INTENT_KEY_TEXT); } } } final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme()) ? new File(mImageUri.getPath()) : null; final boolean image_file_valid = image_file != null && image_file.exists(); mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE); if (image_file_valid) { reloadAttachedImageThumbnail(image_file); } mImageThumbnailPreview.setOnClickListener(this); mImageThumbnailPreview.setOnLongClickListener(this); mMenuBar.setOnMenuItemClickListener(this); mMenuBar.inflate(R.menu.menu_compose); mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance()); mEditText.setImeOptions(EditorInfo.IME_ACTION_GO); mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); if (mText != null) { mEditText.setText(mText); if (mIsQuote) { mEditText.setSelection(0); } else if (text_selection_start != -1 && text_selection_start < mEditText.length() && mEditText.length() > 0) { mEditText.setSelection(text_selection_start, mEditText.length() - 1); } else if (mEditText.length() > 0) { mEditText.setSelection(mEditText.length()); } } invalidateSupportOptionsMenu(); setMenu(); if (mColorIndicator != null) { mColorIndicator.setOrientation(ColorView.VERTICAL); mColorIndicator.setColor(getAccountColors(this, mAccountIds)); } mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED) : false; mIsPossiblySensitive = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE) : false; }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent();//ww w. j a v a 2 s. c o m if (mInWriteMode) { if (intent != null) { String action = intent.getAction(); if (mInWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) && intent.hasExtra(EXTRA_DEVICE_NAME)) { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); String name = intent.getStringExtra(EXTRA_DEVICE_NAME); if ((tag != null) && (name != null)) { // write the device and address String lang = "en"; // don't write the passphrase! byte[] textBytes = name.getBytes(); byte[] langBytes = null; int langLength = 0; try { langBytes = lang.getBytes("US-ASCII"); langLength = langBytes.length; } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } int textLength = textBytes.length; byte[] payload = new byte[1 + langLength + textLength]; // set status byte (see NDEF spec for actual bits) payload[0] = (byte) langLength; // copy langbytes and textbytes into payload if (langBytes != null) { System.arraycopy(langBytes, 0, payload, 1, langLength); } System.arraycopy(textBytes, 0, payload, 1 + langLength, textLength); NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], payload); NdefMessage message = new NdefMessage( new NdefRecord[] { record, NdefRecord.createApplicationRecord(getPackageName()) }); // Get an instance of Ndef for the tag. Ndef ndef = Ndef.get(tag); if (ndef != null) { try { ndef.connect(); if (ndef.isWritable()) { ndef.writeNdefMessage(message); } ndef.close(); Toast.makeText(this, "tag written", Toast.LENGTH_LONG).show(); } catch (IOException e) { Log.e(TAG, e.toString()); } catch (FormatException e) { Log.e(TAG, e.toString()); } } else { NdefFormatable format = NdefFormatable.get(tag); if (format != null) { try { format.connect(); format.format(message); format.close(); Toast.makeText(getApplicationContext(), "tag written", Toast.LENGTH_LONG); } catch (IOException e) { Log.e(TAG, e.toString()); } catch (FormatException e) { Log.e(TAG, e.toString()); } } } mNfcAdapter.disableForegroundDispatch(this); } } } mInWriteMode = false; } else { SharedPreferences sp = getSharedPreferences(KEY_PREFS, MODE_PRIVATE); onSharedPreferenceChanged(sp, KEY_DEVICES); // check if configuring a widget if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { final String[] displayNames = TapLock.getDeviceNames(mDevices); final int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle("Select device for widget") .setItems(displayNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // set the successful widget result Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_OK, resultValue); // broadcast the new widget to update JSONObject deviceJObj = mDevices.get(which); dialog.cancel(); TapLockSettings.this.finish(); try { sendBroadcast(TapLock .getPackageIntent(TapLockSettings.this, TapLockWidget.class) .setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId) .putExtra(EXTRA_DEVICE_NAME, deviceJObj.getString(KEY_NAME))); } catch (JSONException e) { Log.e(TAG, e.toString()); } } }).create(); mDialog.show(); } } } // start the service before binding so that the service stays around for faster future connections startService(TapLock.getPackageIntent(this, TapLockService.class)); bindService(TapLock.getPackageIntent(this, TapLockService.class), this, BIND_AUTO_CREATE); int serverVersion = sp.getInt(KEY_SERVER_VERSION, 0); if (mShowTapLockSettingsInfo && (mDevices.size() == 0)) { if (serverVersion < SERVER_VERSION) sp.edit().putInt(KEY_SERVER_VERSION, SERVER_VERSION).commit(); mShowTapLockSettingsInfo = false; Intent i = TapLock.getPackageIntent(this, TapLockInfo.class); i.putExtra(EXTRA_INFO, getString(R.string.info_taplocksettings)); startActivity(i); } else if (serverVersion < SERVER_VERSION) { // TapLockServer has been updated sp.edit().putInt(KEY_SERVER_VERSION, SERVER_VERSION).commit(); mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.ttl_hasupdate) .setMessage(R.string.msg_hasupdate) .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickinstaller) .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); final String installer_file = getResources() .getStringArray(R.array.installer_values)[which]; mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickdownloader) .setItems(R.array.download_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String action = getResources() .getStringArray( R.array.download_values)[which]; if (ACTION_DOWNLOAD_SDCARD.equals(action) && copyFileToSDCard(installer_file)) Toast.makeText(TapLockSettings.this, "Done!", Toast.LENGTH_SHORT) .show(); else if (ACTION_DOWNLOAD_EMAIL .equals(action) && copyFileToSDCard( installer_file)) { Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); emailIntent.setType( "application/java-archive"); emailIntent.putExtra(Intent.EXTRA_TEXT, getString( R.string.email_instructions)); emailIntent.putExtra( Intent.EXTRA_SUBJECT, getString(R.string.app_name)); emailIntent.putExtra( Intent.EXTRA_STREAM, Uri.parse("file://" + Environment .getExternalStorageDirectory() .getPath() + "/" + installer_file)); startActivity(Intent.createChooser( emailIntent, getString( R.string.button_getserver))); } } }) .create(); mDialog.show(); } }).create(); mDialog.show(); } }).create(); mDialog.show(); } } }
From source file:com.htc.dotdesign.DrawingView.java
private void sharePicture() { if (mContext == null) { return;//from w w w. j av a 2s . c o m } Bitmap bitmap = null; Bitmap scaledBmp = null; try { bitmap = handlePicture(); scaledBmp = Bitmap.createScaledBitmap(bitmap, DotDesignConstants.SHARE_PHOTO_WIDTH, DotDesignConstants.SHARE_PHOTO_HEIGHT, false); DotDesignUtil.SaveImagetoExternal(scaledBmp, mContext); } catch (Exception e) { e.printStackTrace(); } finally { if (scaledBmp != null && !scaledBmp.isRecycled()) { scaledBmp.recycle(); scaledBmp = null; } if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); bitmap = null; } } File tmpFile = new File(mContext.getExternalFilesDir(null), DotDesignConstants.shareName); Intent shareintent = new Intent(Intent.ACTION_SEND); shareintent.setType("image/png"); shareintent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tmpFile)); mContext.startActivity(Intent.createChooser(shareintent, "Share")); }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
final public void sendLogFileToDeveloper(String log_file_path) { CommonLogUtil.resetLogReceiver(mContext, mGp); String zip_file_name = mGp.getLogDirName() + "log.zip"; File lf = new File(zip_file_name); lf.delete();// w ww. j a v a 2 s.c o m // createZipFile(zip_file_name,log_file_path); String[] lmp = LocalMountPoint.convertFilePathToMountpointFormat(mContext, log_file_path); ZipUtil.createZipFile(mContext, null, null, zip_file_name, lmp[0], log_file_path); Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_SEND); // intent.setType("message/rfc822"); // intent.setType("text/plain"); intent.setType("application/zip"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "gm.developer.fhoshino@gmail.com" }); // intent.putExtra(Intent.EXTRA_CC, new String[]{"cc@example.com"}); // intent.putExtra(Intent.EXTRA_BCC, new String[]{"bcc@example.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "Log file"); intent.putExtra(Intent.EXTRA_TEXT, "Any comment"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(lf)); mContext.startActivity(intent); }
From source file:com.visva.voicerecorder.utils.Utils.java
public static void shareRecordingSessionAction(Context context, String fileName) { File file = new File(fileName); if (!file.exists()) { AIOLog.e(MyCallRecorderConstant.TAG, "file not found"); }//from w w w . j a va 2 s . c o m Uri uri = Uri.fromFile(file); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("*/*"); context.startActivity(Intent.createChooser(shareIntent, "Share via")); }