List of usage examples for android.content Intent ACTION_SEND
String ACTION_SEND
To view the source code for android.content Intent ACTION_SEND.
Click Source Link
From source file:com.gelakinetic.mtgfam.fragments.TradeFragment.java
/** * Build a plaintext trade and share it. *///from w w w . j av a 2s. co m private void shareTrade() { StringBuilder sb = new StringBuilder(); /* Add all the cards to the StringBuilder from the left, tallying the price */ float totalPrice = 0; for (MtgCard card : mListLeft) { totalPrice += (card.toTradeShareString(sb, getString(R.string.wishlist_foil)) / 100.0f); } sb.append(String.format(Locale.US, PRICE_FORMAT + "%n", totalPrice)); /* Simple divider */ sb.append("--------\n"); /* Add all the cards to the StringBuilder from the right, tallying the price */ totalPrice = 0; for (MtgCard card : mListRight) { totalPrice += (card.toTradeShareString(sb, getString(R.string.wishlist_foil)) / 100.0f); } sb.append(String.format(Locale.US, PRICE_FORMAT, totalPrice)); /* Send the Intent on it's merry way */ Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, R.string.trade_share_title); sendIntent.putExtra(Intent.EXTRA_TEXT, sb.toString()); sendIntent.setType("text/plain"); try { startActivity(Intent.createChooser(sendIntent, getString(R.string.trader_share))); } catch (android.content.ActivityNotFoundException ex) { ToastWrapper.makeAndShowText(getActivity(), R.string.error_no_email_client, ToastWrapper.LENGTH_SHORT); } }
From source file:it.mb.whatshare.MainActivity.java
private void onTellFriendsSelected() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(getResources().getString(R.string.email_body))); startActivity(Intent.createChooser(intent, getResources().getString(R.string.email_intent_msg))); }
From source file:com.agustinprats.myhrv.MainActivity.java
protected void sendFileByEmail(File file) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "eladfein@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Testing result of HRV bluetooth monitor"); intent.putExtra(Intent.EXTRA_TEXT, "see files attached"); Uri uri = Uri.fromFile(file);/* w w w .j av a 2s. c o m*/ intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intent, "Send email...")); }
From source file:com.nbplus.hybrid.BasicWebViewClient.java
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // for excel download if (isDocumentMimeType(url)) { Log.d(TAG, "This url is document mimetype = " + url); if (StorageUtils.isExternalStorageWritable()) { Uri source = Uri.parse(url); // Make a new request pointing to the mp3 url DownloadManager.Request request = new DownloadManager.Request(source); // Use the same file name for the destination File destinationFile = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), source.getLastPathSegment()); request.setDestinationUri(Uri.fromFile(destinationFile)); // Add it to the manager mDownloadManager.enqueue(request); Toast.makeText(mContext, R.string.downloads_requested, Toast.LENGTH_SHORT).show(); } else {/*www .ja v a 2s .c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setPositiveButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //closeWebApplication(); } }); builder.setMessage(R.string.downloads_path_check); builder.show(); } return true; } if (url.startsWith("tel:")) { // phone call if (!PhoneState.hasPhoneCallAbility(mContext)) { Log.d(TAG, ">> This device has not phone call ability !!!"); return true; } mContext.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url))); } else if (url.startsWith("mailto:")) { url = url.replaceFirst("mailto:", ""); url = url.trim(); Intent i = new Intent(Intent.ACTION_SEND); i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[] { url }); mContext.startActivity(i); } else if (url.startsWith("geo:")) { Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); mContext.startActivity(searchAddress); } else { // URL ?? ? ??? . dismissProgressDialog(); loadWebUrl(url); showProgressDialog(); } return true; }
From source file:net.gerosyab.dailylog.activity.MainActivity.java
private void exportCategory(final long id) { //?? ? ?? csv //? ?? ?? /*from www . j ava2 s .c o m*/ // ? ? ? ? Category category = categories.get((int) id); ProgressDialog progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setTitle("Exporting data [" + category.getName() + "]"); progressDialog.show(); String filename = category.getName() + "" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".data"; FileOutputStream outputStream = null; File resultFilePath = null; File resultFile = null; CSVWriter cw = null; try { resultFile = new File(context.getCacheDir(), filename); outputStream = new FileOutputStream(resultFile.getAbsolutePath()); // cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"),'\t', '"'); cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"), ',', '"'); // Export Data String[] metaDataStr = { "Version:" + AppDatabase.VERSION, "Name:" + category.getName(), "Unit:" + category.getUnit(), "Type:" + category.getRecordType(), "DefaultValue:" + category.getDefaultValue(), "Columns:date(yyyy-MM-dd 24HH:mm:ss)/value(boolean|numeric|string)" }; cw.writeNext(metaDataStr); List<Record> records = category.getRecordsOrderByDateAscending(realm); for (Record record : records) { String value = null; if (category.getRecordType() == StaticData.RECORD_TYPE_BOOLEAN) { value = "true"; } else if (category.getRecordType() == StaticData.RECORD_TYPE_NUMBER) { value = "" + record.getNumber(); } else if (category.getRecordType() == StaticData.RECORD_TYPE_MEMO) { value = record.getString(); } String[] s = { record.getDateString(StaticData.fmtForBackup), value }; cw.writeNext(s); } cw.close(); outputStream.close(); progressDialog.dismiss(); Uri fileUri = FileProvider.getUriForFile(context, "net.gerosyab.dailylog.fileprovider", resultFile); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri); shareIntent.setType("text/plain"); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); } catch (UnsupportedEncodingException e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } catch (Exception e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } finally { progressDialog.dismiss(); } }
From source file:com.silentcircle.silenttext.util.DeviceUtils.java
public static Intent getShareDebugInformationIntent(Context context) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", context.getString(R.string.support_email_address), null)); intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.support_email_subject)); intent.putExtra(Intent.EXTRA_TEXT, wrap(LABEL_DEBUG_INFO, getDebugInformation(context))); ResolveInfo info = context.getPackageManager().resolveActivity(intent, 0); if (info == null) { intent.setAction(Intent.ACTION_SEND); intent.setDataAndType(null, "text/plain"); }//from w w w. j a v a 2 s .c o m return Intent.createChooser(intent, context.getString(R.string.share_with, context.getString(R.string.feedback))); }
From source file:co.dilaver.quoter.activities.ShareActivity.java
private void save() { previewLayout.setDrawingCacheEnabled(true); previewLayout.buildDrawingCache();//from w w w.j a v a 2s . c om Bitmap bmp = Bitmap.createBitmap(previewLayout.getDrawingCache()); previewLayout.setDrawingCacheEnabled(false); ContextWrapper cw = new ContextWrapper(this); File directory = cw.getExternalFilesDir(null); if (!directory.exists()) { directory.mkdir(); } File image = new File(directory, "image.jpg"); FileOutputStream fos; try { fos = new FileOutputStream(image); bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.close(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + image.getAbsolutePath())); shareIntent.setType("image/jpeg"); startActivity(Intent.createChooser(shareIntent, getString(R.string.str_ShareWith))); }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
public void handleExportTransactions() { // Create CSV file from transactions final File file = new File(Constants.Files.EXTERNAL_WALLET_BACKUP_DIR, Constants.Files.TX_EXPORT_NAME + "-" + getFileDate() + ".csv"); try {/*from w ww. j a va2 s . c o m*/ final BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append("Date,Label,Amount (" + MonetaryFormat.CODE_PPC + "),Fee (" + MonetaryFormat.CODE_PPC + "),Address,Transaction Hash,Confirmations\n"); if (txListAdapter == null || txListAdapter.transactions.isEmpty()) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed"); return; } final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm z"); dateFormat.setTimeZone(TimeZone.getDefault()); for (Transaction tx : txListAdapter.transactions) { TransactionsListAdapter.TransactionCacheEntry txCache = txListAdapter.getTxCache(tx); String memo = tx.getMemo() == null ? "" : StringEscapeUtils.escapeCsv(tx.getMemo()); String fee = tx.getFee() == null ? "" : tx.getFee().toPlainString(); String address = txCache.address == null ? getString(R.string.export_transactions_unknown) : txCache.address.toString(); writer.append(dateFormat.format(tx.getUpdateTime()) + ","); writer.append(memo + ","); writer.append(txCache.value.toPlainString() + ","); writer.append(fee + ","); writer.append(address + ","); writer.append(tx.getHash().toString() + ","); writer.append(tx.getConfidence().getDepthInBlocks() + "\n"); } writer.flush(); writer.close(); } catch (IOException x) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed", x); return; } final DialogBuilder dialog = new DialogBuilder(this); dialog.setMessage(Html.fromHtml(getString(R.string.export_transactions_dialog_success, file))); dialog.setPositiveButton(WholeStringBuilder.bold(getString(R.string.export_keys_dialog_button_archive)), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_transactions_mail_subject)); intent.putExtra(Intent.EXTRA_TEXT, makeEmailText(getString(R.string.export_transactions_mail_text))); intent.setType(Constants.MIMETYPE_TX_EXPORT); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); try { startActivity(Intent.createChooser(intent, getString(R.string.export_transactions_mail_intent_chooser))); log.info("invoked chooser for exporting transactions"); } catch (final Exception x) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed", x); } } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); }
From source file:com.support.android.designlibdemo.activities.CampaignDetailActivity.java
public void setupShareIntent() { // Fetch Bitmap Uri locally ImageView ivImage = (ImageView) findViewById(R.id.ivCampaighnImage); // Get access to the URI for the bitmap Uri bmpUri = getLocalBitmapUri(ivImage); if (bmpUri != null) { // Construct a ShareIntent with link to image Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); shareIntent.putExtra(Intent.EXTRA_SUBJECT, campaign.getTitle()); shareIntent.putExtra(Intent.EXTRA_TEXT, campaign.getCampaignUrl()); shareIntent.setType("image/*"); // Launch sharing dialog for image startActivity(Intent.createChooser(shareIntent, "send")); } else {//from ww w .ja v a 2 s .c o m Toast.makeText(this, "Some error occured during sharing", Toast.LENGTH_LONG).show(); } }