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:de.golov.zeitgeistreich.ZeitGeistReichActivity.java
protected void submitImage(String tags) { Intent intent = getIntent();/*from w ww . j a v a 2 s . c om*/ Bundle extras = intent.getExtras(); Uri mImageUri = null; File mFilename = null; if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) { if (extras.containsKey(Intent.EXTRA_STREAM)) { mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (mImageUri != null) { Cursor cursor = getContentResolver().query(mImageUri, null, null, null, null); if (cursor.moveToFirst()) { mFilename = new File(cursor.getString(cursor.getColumnIndexOrThrow(ImageColumns.DATA))); } cursor.close(); if (mFilename != null) { ZeitGeistReichUploaderTask task = new ZeitGeistReichUploaderTask(); ZeitGeistObject o = new ZeitGeistObject(mFilename, tags); task.execute(o); } } } } }
From source file:ayushi.view.fragment.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_settings, container, false); getActivity().setTitle("About App"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }// w w w . j ava 2s . c o m if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); submitLog = (TextView) rootView.findViewById(R.id.submit_log_txt); if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true)) { submitLog.setText("Disable"); } else { submitLog.setText("Enable"); } rootView.findViewById(R.id.submit_log).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true)) { PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, false); submitLog.setText("Disable"); } else { PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true); submitLog.setText("Enable"); } } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.picasso).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/square/picasso")); startActivity(browserIntent); } }); rootView.findViewById(R.id.acra).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ACRA/acra")); startActivity(browserIntent); } }); rootView.findViewById(R.id.pull_zoom_view).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Frank-Zhu/PullZoomView")); startActivity(browserIntent); } }); rootView.findViewById(R.id.list_buddies).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jpardogo/ListBuddies")); startActivity(browserIntent); } }); rootView.findViewById(R.id.list_jazzy).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/twotoasters/JazzyListView")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "serveroverloadofficial@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:ar.com.lapotoca.resiliencia.gallery.ui.ImageDetailActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.image_menu, menu); MenuItem shareItem = menu.findItem(R.id.menu_share); shareItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*w w w . jav a 2s . c o m*/ public boolean onMenuItemClick(MenuItem item) { try { ImageHolder img = Images.image[mPager.getCurrentItem()]; if (img == null) { return false; } AnalyticsHelper.getInstance().sendImageShareEvent(img.getUrl()); Uri bmpUri; if (img.isLocal()) { bmpUri = Uri.parse("content://" + AssetProvider.CONTENT_URI + "/" + img.getUrl()); } else { ImageView iv = (ImageView) findViewById(R.id.picImageView); bmpUri = getLocalBitmapUri(iv); } if (bmpUri != null) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); shareIntent.setType("image/*"); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_item))); AnalyticsHelper.getInstance().sendImageShareCompleted(); return true; } else { AnalyticsHelper.getInstance().sendImageShareCanceled(); return false; } } catch (Exception e) { AnalyticsHelper.getInstance().sendImageShareFailed(e.getMessage()); return false; } } }); MenuItem downloadItem = menu.findItem(R.id.download_asset); downloadItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Context context = ImageDetailActivity.this; String appDirectoryName = context.getString(R.string.app_name); File imageRoot = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appDirectoryName); ImageHolder img = Images.image[mPager.getCurrentItem()]; if (img == null) { return false; } AssetManager assetManager = context.getAssets(); try { InputStream is = assetManager.open(img.getUrl()); String fileName = img.getUrl().split("/")[1]; imageRoot.mkdirs(); File image = new File(imageRoot, fileName); byte[] buffer = new byte[BUFFER_LENGHT]; FileOutputStream fos = new FileOutputStream(image); int read = 0; while ((read = is.read(buffer, 0, 1024)) >= 0) { fos.write(buffer, 0, read); } fos.flush(); fos.close(); is.close(); String[] paths = { image.getAbsolutePath() }; MediaScannerConnection.scanFile(context, paths, null, null); NotificationHelper.showNotification(context, context.getString(R.string.download_image_succesfull)); AnalyticsHelper.getInstance().sendDownloadImage(fileName); } catch (Exception e) { NotificationHelper.showNotification(context, context.getString(R.string.download_no_permissions)); AnalyticsHelper.getInstance().sendImageDownloadFailed(e.getMessage()); } return true; } }); return true; }
From source file:com.codebutler.farebot.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { try {// ww w.java2 s .com if (item.getItemId() == R.id.supported_cards) { startActivity(new Intent(this, SupportedCardsActivity.class)); return true; } else if (item.getItemId() == R.id.about) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://codebutler.github.com/farebot"))); return true; } else if (item.getItemId() == R.id.import_clipboard) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); onCardsImported(ExportHelper.importCardsXml(this, clipboard.getText().toString())); return true; } else if (item.getItemId() == R.id.import_file) { Uri uri = Uri.fromFile(Environment.getExternalStorageDirectory()); Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.putExtra(Intent.EXTRA_STREAM, uri); i.setType("application/xml"); startActivityForResult(Intent.createChooser(i, "Select File"), SELECT_FILE); return true; } else if (item.getItemId() == R.id.import_sd) { String xml = FileUtils.readFileToString(new File(SD_EXPORT_PATH)); onCardsImported(ExportHelper.importCardsXml(this, xml)); return true; } else if (item.getItemId() == R.id.copy_xml) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(ExportHelper.exportCardsXml(this)); Toast.makeText(this, "Copied to clipboard.", 5).show(); return true; } else if (item.getItemId() == R.id.share_xml) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, ExportHelper.exportCardsXml(this)); startActivity(intent); return true; } else if (item.getItemId() == R.id.save_xml) { String xml = ExportHelper.exportCardsXml(this); File file = new File(SD_EXPORT_PATH); FileUtils.writeStringToFile(file, xml, "UTF-8"); Toast.makeText(this, "Wrote FareBot-Export.xml to USB Storage.", 5).show(); return true; } else if (item.getItemId() == R.id.prefs) { startActivity(new Intent(this, FareBotPreferenceActivity.class)); } } catch (Exception ex) { Utils.showError(this, ex); } return false; }
From source file:com.codebutler.farebot.fragments.CardsFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { try {//from w ww . j a v a 2 s . com if (item.getItemId() == R.id.import_clipboard) { @SuppressWarnings("deprecation") ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Activity.CLIPBOARD_SERVICE); onCardsImported(ExportHelper.importCardsXml(getActivity(), clipboard.getText().toString())); return true; } else if (item.getItemId() == R.id.import_file) { Uri uri = Uri.fromFile(Environment.getExternalStorageDirectory()); Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.putExtra(Intent.EXTRA_STREAM, uri); i.setType("application/xml"); startActivityForResult(Intent.createChooser(i, "Select File"), REQUEST_SELECT_FILE); return true; } else if (item.getItemId() == R.id.import_sd) { String xml = FileUtils.readFileToString(new File(SD_EXPORT_PATH)); onCardsImported(ExportHelper.importCardsXml(getActivity(), xml)); return true; } else if (item.getItemId() == R.id.copy_xml) { @SuppressWarnings("deprecation") ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Activity.CLIPBOARD_SERVICE); clipboard.setText(ExportHelper.exportCardsXml(getActivity())); Toast.makeText(getActivity(), "Copied to clipboard.", 5).show(); return true; } else if (item.getItemId() == R.id.share_xml) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, ExportHelper.exportCardsXml(getActivity())); startActivity(intent); return true; } else if (item.getItemId() == R.id.save_xml) { String xml = ExportHelper.exportCardsXml(getActivity()); File file = new File(SD_EXPORT_PATH); FileUtils.writeStringToFile(file, xml, "UTF-8"); Toast.makeText(getActivity(), "Wrote FareBot-Export.xml to USB Storage.", 5).show(); return true; } } catch (Exception ex) { Utils.showError(getActivity(), ex); } return false; }
From source file:com.gmail.altakey.lucene.AsyncImageLoader.java
private InputStream read(ProgressReportingInputStream.ProgressListener listener) throws FileNotFoundException { final Context context = this.view.getContext(); if (Intent.ACTION_SEND.equals(this.intent.getAction())) { final Bundle extras = this.intent.getExtras(); if (extras.containsKey(Intent.EXTRA_STREAM)) return new ProgressReportingInputStream(context.getContentResolver() .openInputStream((Uri) extras.getParcelable(Intent.EXTRA_STREAM)), listener); if (extras.containsKey(Intent.EXTRA_TEXT)) { try { final HttpGet req = new HttpGet(extras.getCharSequence(Intent.EXTRA_TEXT).toString()); return new ProgressReportingInputStream(this.httpClient.execute(req).getEntity().getContent(), listener);/*from ww w .j ava 2 s . c o m*/ } catch (IllegalArgumentException e) { return null; } catch (IOException e) { return null; } } } if (Intent.ACTION_VIEW.equals(this.intent.getAction())) return new ProgressReportingInputStream( context.getContentResolver().openInputStream(this.intent.getData()), listener); return null; }
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** * Called when the activity starts. If the calling intent carries * a text, it places the input in the text edit component. *//* w w w.j ava2 s. c om*/ @Override public void onStart() { super.onStart(); if (Intent.ACTION_SEND.equals(getIntent().getAction())) { Bundle bundle = getIntent().getExtras(); txtInput.setText(bundle.getString(Intent.EXTRA_TEXT)); getIntent().setAction(null); } }
From source file:ca.rmen.android.networkmonitor.app.log.LogActionsActivity.java
/** * Run the given file export, then bring up the chooser intent to share the exported file. *//*from w ww . j av a 2 s . com*/ private void shareFile(final FileExport fileExport) { Log.v(TAG, "shareFile " + fileExport); // Use a horizontal progress bar style if we can show progress of the export. String dialogMessage = getString(R.string.export_progress_preparing_export); int dialogStyle = fileExport != null ? ProgressDialog.STYLE_HORIZONTAL : ProgressDialog.STYLE_SPINNER; DialogFragmentFactory.showProgressDialog(this, dialogMessage, dialogStyle, PROGRESS_DIALOG_TAG); AsyncTask<Void, Void, File> asyncTask = new AsyncTask<Void, Void, File>() { @Override protected File doInBackground(Void... params) { File file = null; if (fileExport != null) { if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) return null; try { // Export the file in the background. file = fileExport.export(); } catch (Throwable t) { Log.e(TAG, "Error exporting file " + fileExport + ": " + t.getMessage(), t); } if (file == null) return null; } String reportSummary = SummaryExport.getSummary(LogActionsActivity.this); // Bring up the chooser to share the file. Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_subject_send_log)); String dateRange = SummaryExport.getDataCollectionDateRange(LogActionsActivity.this); String messageBody = getString(R.string.export_message_text, dateRange); if (file != null) { sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath())); sendIntent.setType("message/rfc822"); messageBody += getString(R.string.export_message_text_file_attached); } else { sendIntent.setType("text/plain"); } messageBody += reportSummary; sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.action_share))); return file; } @Override protected void onPostExecute(File result) { super.onPostExecute(result); DialogFragment fragment = (DialogFragment) getSupportFragmentManager() .findFragmentByTag(PROGRESS_DIALOG_TAG); if (fragment != null) fragment.dismissAllowingStateLoss(); // Show a toast if we failed to export a file. if (fileExport != null && result == null) Toast.makeText(LogActionsActivity.this, R.string.export_error_sdcard_unmounted, Toast.LENGTH_LONG).show(); finish(); } }; asyncTask.execute(); }
From source file:com.agateau.equiv.ui.Kernel.java
public void shareCustomProductList(Context context) { File file = context.getFileStreamPath(CUSTOM_PRODUCTS_CSV); Uri contentUri = FileProvider.getUriForFile(context, "com.agateau.equiv.fileprovider", file); final Resources res = context.getResources(); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.CUSTOM_PRODUCTS_EMAIL }); intent.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.share_email_subject)); intent.putExtra(Intent.EXTRA_STREAM, contentUri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(Intent.createChooser(intent, res.getString(R.string.share_via))); }