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:gr.scify.newsum.ui.ViewActivity.java
private void Sendmail() { TextView title = (TextView) findViewById(R.id.title); String emailSubject = title.getText().toString(); // track the Send mail action if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Send Mail", emailSubject, 0l); }/*from w ww .j a v a2 s . c om*/ final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/html"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "NewSum app : " + emailSubject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(sText)); startActivity(Intent.createChooser(emailIntent, "Email:")); }
From source file:ch.luklanis.esscan.history.HistoryActivity.java
private Intent createShareIntent(String mime, Uri dtaFileUri) { String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") }; String subject = getResources().getString(R.string.history_share_as_dta_title); String text = String.format(getResources().getString(R.string.history_share_as_dta_summary), dtaFileUri.getPath());// www . ja v a 2s . c om Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setType(mime); intent.putExtra(Intent.EXTRA_EMAIL, recipients); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, dtaFileUri); return intent; }
From source file:com.kd.filmstrip.DetailActivityV2.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.detail_like: if (detailImageLoaderv2.user_has_liked) { HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0); liker.execute();//w w w .j a v a 2 s .co m try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } else { animatePhotoLike(); HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0); liker.execute(); try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } break; case R.id.detail_likeCounts: Intent i = new Intent(getBaseContext(), LikersActivity.class); i.putExtra("media_id", detailImageLoaderv2.id); i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")"); startActivity(i); break; case R.id.detail_share: Intent shareIntent = new Intent(); Uri uri = null; // Create share intent as described above if (!detailImageLoaderv2.video) { Drawable mDrawable = detailImageV2.getDrawable(); Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap(); String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name, detailImageLoaderv2.caption); uri = Uri.parse(path); } else { } shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, detailImageLoaderv2.caption + " Posted by @" + detailImageLoaderv2.username); startActivity(Intent.createChooser(shareIntent, "Share To")); break; case R.id.detail_user_pic: viewProfile(this, detailImageLoaderv2); } }
From source file:com.balakrish.gpstracker.WaypointsListActivity.java
/** * Handle activity menu//from www . ja va 2 s . c o m */ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final long waypointId = waypointsArrayAdapter.getItem((int) info.id).getId(); Cursor tmpCursor; String sql; switch (item.getItemId()) { case 0: // update waypoint in db updateWaypoint(waypointId); return true; case 1: deleteWaypoint(waypointId); return true; case 2: // email waypoint data using default email client String elevationUnit = app.getPreferences().getString("elevation_units", "m"); String elevationUnitLocalized = Utils.getLocalizedElevationUnit(this, elevationUnit); sql = "SELECT * FROM waypoints WHERE _id=" + waypointId + ";"; tmpCursor = app.getDatabase().rawQuery(sql, null); tmpCursor.moveToFirst(); double lat1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lat")) / 1E6; double lng1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lng")) / 1E6; String messageBody = getString(R.string.title) + ": " + tmpCursor.getString(tmpCursor.getColumnIndex("title")) + "\n\n" + getString(R.string.lat) + ": " + Utils.formatLat(lat1, 0) + "\n" + getString(R.string.lng) + ": " + Utils.formatLng(lng1, 0) + "\n" + getString(R.string.elevation) + ": " + Utils.formatElevation(tmpCursor.getFloat(tmpCursor.getColumnIndex("elevation")), elevationUnit) + elevationUnitLocalized + "\n\n" + "http://maps.google.com/?ll=" + lat1 + "," + lng1 + "&z=10"; tmpCursor.close(); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_waypoint)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, messageBody); this.startActivity(Intent.createChooser(emailIntent, getString(R.string.sending_email))); return true; case 3: this.showOnMap(waypointId); return true; case 4: // TODO: use a thread for online sync // sync one waypoint data with remote server // create temp waypoint from current record Waypoint wp = Waypoints.get(app.getDatabase(), waypointId); try { // preparing query string for calling web service String lat = Location.convert(wp.getLocation().getLatitude(), 0); String lng = Location.convert(wp.getLocation().getLongitude(), 0); String title = URLEncoder.encode(wp.getTitle()); String userName = app.getPreferences().getString("user_name", ""); String userPassword = app.getPreferences().getString("user_password", ""); String sessionValue = userName + "@" + Utils.md5("aripuca_session" + userPassword); if (userName.equals("") || userPassword.equals("")) { Toast.makeText(WaypointsListActivity.this, R.string.username_or_password_required, Toast.LENGTH_SHORT).show(); return false; } String queryString = "?do=ajax_map_handler&aripuca_session=" + sessionValue + "&action=add_point&lat=" + lat + "&lng=" + lng + "&z=16&n=" + title + "&d=AndroidSync"; // http connection HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet( app.getPreferences().getString("online_sync_url", "http://tracker.aripuca.com") + queryString); HttpResponse response = httpClient.execute(httpGet, localContext); ByteArrayOutputStream outstream = new ByteArrayOutputStream(); response.getEntity().writeTo(outstream); // parsing JSON return JSONObject jsonObject = new JSONObject(outstream.toString()); Toast.makeText(WaypointsListActivity.this, jsonObject.getString("message").toString(), Toast.LENGTH_SHORT).show(); } catch (ClientProtocolException e) { Toast.makeText(WaypointsListActivity.this, "ClientProtocolException: " + e.getMessage(), Toast.LENGTH_SHORT).show(); } catch (IOException e) { Toast.makeText(WaypointsListActivity.this, "IOException " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } catch (JSONException e) { Toast.makeText(WaypointsListActivity.this, "JSONException " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } return true; default: return super.onContextItemSelected(item); } }
From source file:it.feio.android.omninotes.DetailFragment.java
private void handleIntents() { Intent i = mainActivity.getIntent(); if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) { noteOriginal = new Note(); note = new Note(noteOriginal); noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE); if (i.getStringArrayListExtra("merged_notes") != null) { mergedNotesIds = i.getStringArrayListExtra("merged_notes"); }// w w w .ja v a2 s .c o m } // Action called from home shortcut if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) { afterSavedReturnsToList = false; noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0)); // Checks if the note pointed from the shortcut has been deleted try { note = new Note(noteOriginal); noteTmp = new Note(noteOriginal); } catch (NullPointerException e) { mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG); mainActivity.finish(); } } // Check if is launched from a widget if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) { afterSavedReturnsToList = false; showKeyboard = true; // with tags to set tag if (i.hasExtra(Constants.INTENT_WIDGET)) { String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString(); if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); if (categoryId != null) { Category category; try { category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId)); noteTmp = new Note(); noteTmp.setCategory(category); } catch (NumberFormatException e) { Log.e(Constants.TAG, "Category with not-numeric value!", e); } } } } // Sub-action is to take a photo if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) { takePhoto(); } } /** * Handles third party apps requests of sharing */ if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE, Constants.INTENT_GOOGLE_NOW) && i.getType() != null) { afterSavedReturnsToList = false; if (noteTmp == null) noteTmp = new Note(); // Text title String title = i.getStringExtra(Intent.EXTRA_SUBJECT); if (title != null) { noteTmp.setTitle(title); } // Text content String content = i.getStringExtra(Intent.EXTRA_TEXT); if (content != null) { noteTmp.setContent(content); } // Single attachment data Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM); // Due to the fact that Google Now passes intent as text but with // audio recording attached the case must be handled in specific way if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) { String name = FileHelper.getNameFromUri(mainActivity, uri); AttachmentTask task = new AttachmentTask(this, uri, name, this); task.execute(); } // Multiple attachment data ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { for (Uri uriSingle : uris) { String name = FileHelper.getNameFromUri(mainActivity, uriSingle); AttachmentTask task = new AttachmentTask(this, uriSingle, name, this); task.execute(); } } // i.setAction(null); } if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST)) { showKeyboard = true; } }
From source file:com.cerema.cloud2.files.FileOperationsHelper.java
public void sendDownloadedFile(OCFile file) { if (file != null) { String storagePath = file.getStoragePath(); String encodedStoragePath = WebdavUtils.encodePath(storagePath); Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); // set MimeType sendIntent.setType(file.getMimetype()); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath)); sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action // Show dialog, without the own app String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude); chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); } else {//w w w . j a v a 2 s.co m Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); } }
From source file:com.farmerbb.notepad.fragment.NoteViewFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // Override default Android "up" behavior to instead mimic the back button getActivity().onBackPressed();/*w ww .j av a2 s .com*/ return true; // Edit button case R.id.action_edit: Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return true; // Delete button case R.id.action_delete: listener.showDeleteDialog(); return true; // Share menu item case R.id.action_share: // Send a share intent Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, contentsOnLoad); intent.setType("text/plain"); // Verify that the intent will resolve to an activity, and send if (intent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(Intent.createChooser(intent, getResources().getText(R.string.send_to))); return true; // Export menu item case R.id.action_export: listener.exportNote(filename); return true; // Print menu item case R.id.action_print: listener.printNote(contentsOnLoad); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (fileOpened && searchResult != null) { MenuItem imReplace = menu.findItem(R.id.im_replace); MenuItem imReplaceAll = menu.findItem(R.id.im_replace_all); MenuItem imPrev = menu.findItem(R.id.im_previous_item); MenuItem imNext = menu.findItem(R.id.im_next_item); if (imReplace != null) imReplace.setVisible(searchResult.canReplaceSomething()); if (imReplaceAll != null) imReplaceAll.setVisible(searchResult.canReplaceSomething()); if (imPrev != null) imPrev.setVisible(searchResult.hasPrevious()); if (imNext != null) imNext.setVisible(searchResult.hasNext()); } else if (fileOpened) { MenuItem imSave = menu.findItem(R.id.im_save); MenuItem imUndo = menu.findItem(R.id.im_undo); MenuItem imRedo = menu.findItem(R.id.im_redo); if (mEditor != null) { if (imSave != null) imSave.setVisible(mEditor.canSaveFile()); if (imUndo != null) imUndo.setVisible(mEditor.getCanUndo()); if (imRedo != null) imRedo.setVisible(mEditor.getCanRedo()); } else {/*from www. ja va2s. c o m*/ imSave.setVisible(false); imUndo.setVisible(false); imRedo.setVisible(false); } MenuItem imMarkdown = menu.findItem(R.id.im_view_markdown); boolean isMarkdown = Arrays.asList(MimeTypes.MIME_MARKDOWN) .contains(FilenameUtils.getExtension(greatUri.getFileName())); if (imMarkdown != null) imMarkdown.setVisible(isMarkdown); MenuItem imShare = menu.findItem(R.id.im_share); if (imMarkdown != null) { ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(imShare); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, greatUri.getUri()); shareIntent.setType("text/plain"); shareAction.setShareIntent(shareIntent); } } return true; }
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Export data./*from w w w . j av a2s . c om*/ * * @param descr * description of the exported rule set * @param fn * one of the predefined file names from {@link DataProvider}. */ private void exportData(final String descr, final String fn) { if (descr == null) { final EditText et = new EditText(this); Builder builder = new Builder(this); builder.setView(et); builder.setCancelable(true); builder.setTitle(R.string.export_rules_descr); builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Preferences.this.exportData(et.getText().toString(), fn); } }); builder.show(); } else { final ProgressDialog d = new ProgressDialog(this); d.setIndeterminate(true); d.setMessage(this.getString(R.string.export_progr)); d.setCancelable(false); d.show(); // run task in background final AsyncTask<Void, Void, String> task = // . new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(final Void... params) { if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) { return DataProvider.backupRuleSet(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) { return DataProvider.backupLogs(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) { return DataProvider.backupNumGroups(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) { return DataProvider.backupHourGroups(Preferences.this, descr); } return null; } @Override protected void onPostExecute(final String result) { Log.d(TAG, "export:\n" + result); System.out.println("\n" + result); d.dismiss(); if (result != null && result.length() > 0) { Uri uri = null; int resChooser = -1; if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) { uri = DataProvider.EXPORT_RULESET_URI; resChooser = R.string.export_rules_; } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) { uri = DataProvider.EXPORT_LOGS_URI; resChooser = R.string.export_logs_; } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) { uri = DataProvider.EXPORT_NUMGROUPS_URI; resChooser = R.string.export_numgroups_; } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) { uri = DataProvider.EXPORT_HOURGROUPS_URI; resChooser = R.string.export_hourgroups_; } final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(DataProvider.EXPORT_MIMETYPE); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.putExtra(Intent.EXTRA_SUBJECT, // . "Call Meter 3G export"); intent.addCategory(Intent.CATEGORY_DEFAULT); try { final File d = Environment.getExternalStorageDirectory(); final File f = new File(d, DataProvider.PACKAGE + File.separator + fn); f.mkdirs(); if (f.exists()) { f.delete(); } f.createNewFile(); FileWriter fw = new FileWriter(f); fw.append(result); fw.close(); // call an exporting app with the uri to the // preferences Preferences.this.startActivity( Intent.createChooser(intent, Preferences.this.getString(resChooser))); } catch (IOException e) { Log.e(TAG, "error writing export file", e); Toast.makeText(Preferences.this, R.string.err_export_write, Toast.LENGTH_LONG) .show(); } } } }; task.execute((Void) null); } }