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.linkbubble.Settings.java
private void setDefaultLeftConsumeBubble() { String leftConsumeBubblePackageName = mSharedPreferences .getString(PREFERENCE_LEFT_CONSUME_BUBBLE_PACKAGE_NAME, null); if (leftConsumeBubblePackageName == null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); PackageManager packageManager = mContext.getPackageManager(); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, 0); if (setDefaultLeftConsumeBubble( findResolveInfoForPackageName(resolveInfos, Constant.POCKET_PACKAGE_NAME), packageManager) == false) { if (setDefaultLeftConsumeBubble( findResolveInfoForPackageName(resolveInfos, "com.instapaper.android"), packageManager) == false) { if (setDefaultLeftConsumeBubble( findResolveInfoForPackageName(resolveInfos, "com.facebook.katana"), packageManager) == false) { if (setDefaultLeftConsumeBubble( findResolveInfoForPackageName(resolveInfos, "com.twitter.android"), packageManager) == false) { if (setDefaultLeftConsumeBubble( findResolveInfoForPackageName(resolveInfos, "com.google.android.apps.plus"), packageManager) == false) { if (setDefaultLeftConsumeBubble( findResolveInfoForPackageName(resolveInfos, "com.google.android.gm"), packageManager) == false) { // Can't imagine *none* of the above apps will not be installed too often, but if so, fall back to the first item in the list... setDefaultLeftConsumeBubble(resolveInfos.get(0), packageManager); }//from ww w.j a va 2s.c om } } } } } } }
From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java
/** * /** Used to shared what the user is currently listening to *//*from w w w. j a v a 2 s .c o m*/ private void shareCurrentTrack() { if (MusicUtils.getTrackName() == null || MusicUtils.getArtistName() == null) { return; } final Intent shareIntent = new Intent(); final String shareMessage = getString(R.string.now_listening_to) + " " + MusicUtils.getTrackName() + " " + getString(R.string.by) + " " + MusicUtils.getArtistName() + " " + getString(R.string.hash_apollo); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_track_using))); }
From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java
void init() { // img=(ImageView)findViewById(R.id.logo); TextView build = (TextView) findViewById(R.id.checkfornew); build.setOnClickListener(new View.OnClickListener() { @Override//from www. j a va 2 s .c o m public void onClick(View v) { if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } CommonUtilities.logMe("about to check for version "); try { WebServiceHandler wsb = new WebServiceHandler(); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String result = wsb.getWebServiceData("http://doe.emergencyskills.com/api/version.php", postParameters); JSONObject jsonObject = new JSONObject(result); String version = jsonObject.getString("version"); String features = jsonObject.getString("features"); System.err.println("version is : " + version); if (!LoginActivity.myversion.equals(version)) { MyToast.popmessagelong( "There is a new build available. Please download for these features: " + features, TabsActivity.this); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vireo.org/esiapp")); browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(browserIntent); } else { MyToast.popmessagelong("You have the most current version!", TabsActivity.this); } } catch (Exception exc) { exc.printStackTrace(); } } }); TextView maillog = (TextView) findViewById(R.id.maillog); maillog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); TextView question = (TextView) dialog.findViewById(R.id.question); question.setText("Are you sure you want to email the log?"); TextView extra = (TextView) dialog.findViewById(R.id.extratext); extra.setText(""); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { "rachelc@gmail.com" }); i.putExtra(Intent.EXTRA_SUBJECT, "Sending Log"); i.putExtra(Intent.EXTRA_TEXT, "body of email"); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(TabsActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); listops listops = new listops(TabsActivity.this); CommonUtilities.logMe("logging in as: " + listops.getString("firstname")); TextView name = (TextView) findViewById(R.id.welcome); name.setText("Welcome, " + listops.getString("firstname")); TextView logoutname = (TextView) findViewById(R.id.logoutname); logoutname.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); dialog.setContentView(R.layout.dialog_logout); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyToast.popmessagelong("Logging out... ", TabsActivity.this); SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.loginkey, ""); editor.commit(); listops listops = new listops(TabsActivity.this); //make sure to remove the downloaded schools Intent intent = new Intent(TabsActivity.this, LoginActivity.class); startActivity(intent); ArrayList<Schoolinfomodel> ls = new ArrayList<Schoolinfomodel>(); listops.putdrilllist(ls); listops.putservicelist(ls); listops.putinstallllist(ls); ArrayList<PendingUploadModel> l = new ArrayList<PendingUploadModel>(); listops.putpendinglist(l); finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); ll1 = (LinearLayout) findViewById(R.id.ll1); ll2 = (LinearLayout) findViewById(R.id.ll2); ll3 = (LinearLayout) findViewById(R.id.ll3); ll4 = (LinearLayout) findViewById(R.id.ll4); ll5 = (LinearLayout) findViewById(R.id.ll5); ll6 = (LinearLayout) findViewById(R.id.ll6); ll1.setBackgroundColor(getResources().getColor(R.color.White)); llPickSchools = (LinearLayout) findViewById(R.id.llPickSchool); llDrills = (LinearLayout) findViewById(R.id.llDrills); llServiceCalls = (LinearLayout) findViewById(R.id.llServiceCalls); llNewInstalls = (LinearLayout) findViewById(R.id.llNewInstalls); llPendingUploads = (LinearLayout) findViewById(R.id.llPendingUploads); frameLayout = (FrameLayout) findViewById(R.id.frame); }
From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java
private void shareLink() { GalleryItemViewTag tag = getCurrentTag(); if (tag == null) return;//from w w w .ja va2 s . co m String absoluteUrl = remote.getAbsoluteUrl(tag.attachmentModel.path); if (absoluteUrl == null) return; Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, absoluteUrl); shareIntent.putExtra(Intent.EXTRA_TEXT, absoluteUrl); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_via))); }
From source file:fi.mikuz.boarder.gui.DropboxMenu.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.menu_share: Thread thread = new Thread() { public void run() { Looper.prepare();/*from ww w. j av a 2 s . co m*/ try { final ArrayList<String> boards = mCbla.getAllSelectedTitles(); if (!(mOperation == DOWNLOAD_OPERATION)) { mToastMessage = "Select 'Download' mode"; mHandler.post(mShowToast); } else if (boards.size() < 1) { mToastMessage = "Select boards to share"; mHandler.post(mShowToast); } else { String shareString = "I want to share some cool soundboards to you!\n\n" + "To use the boards you need to have Boarder for Android:\n" + ExternalIntent.mExtLinkMarket + "\n\n" + "Here are the boards:\n"; for (String board : boards) { shareString += board + " - " + mApi.createCopyRef("/" + board).copyRef + "\n"; } shareString += "\n\n" + "Importing a board:\n" + "1. Open Boarder'\n" + "2. Open Dropbox from menu in 'Soundboard Menu'\n" + "3. Open 'Import share' from menu\n" + "4. Copy a reference from above to textfield\n"; Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sharing boards"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareString); startActivity(Intent.createChooser(sharingIntent, "Share via")); } } catch (DropboxException e) { Log.e(TAG, "Unable to share", e); } } }; thread.start(); return true; case R.id.menu_import_share: LayoutInflater removeInflater = (LayoutInflater) DropboxMenu.this .getSystemService(LAYOUT_INFLATER_SERVICE); View importLayout = removeInflater.inflate(R.layout.dropbox_menu_alert_import_share, (ViewGroup) findViewById(R.id.alert_remove_sound_root)); AlertDialog.Builder importBuilder = new AlertDialog.Builder(DropboxMenu.this); importBuilder.setView(importLayout); importBuilder.setTitle("Import share"); final EditText importCodeInput = (EditText) importLayout.findViewById(R.id.importCodeInput); final EditText importNameInput = (EditText) importLayout.findViewById(R.id.importNameInput); importBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { t = new Thread() { public void run() { Looper.prepare(); try { mApi.addFromCopyRef(importCodeInput.getText().toString(), "/" + importNameInput.getText().toString()); mToastMessage = "Download the board from 'Download'"; mHandler.post(mShowToast); } catch (DropboxException e) { Log.e(TAG, "Unable to get shared board", e); } } }; t.start(); } }); importBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); importBuilder.show(); return true; } return super.onMenuItemSelected(featureId, item); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.list.TaskListFragment.java
private void shareSelected(Collection<Long> orgItemIds) { // This solves threading issues final long[] itemIds = ArrayHelper.toArray(orgItemIds); AsyncTaskHelper.background(new AsyncTaskHelper.Job() { @Override//from w w w . j av a 2s .c o m public void doInBackground() { final StringBuilder shareSubject = new StringBuilder(); final StringBuilder shareText = new StringBuilder(); final String whereId = new StringBuilder(Task.Columns._ID).append(" IN (") .append(DAO.arrayToCommaString(itemIds)).append(")").toString(); Cursor c = getContext().getContentResolver().query(Task.URI, new String[] { Task.Columns._ID, Task.Columns.TITLE, Task.Columns.NOTE }, whereId, null, null); if (c != null) { while (c.moveToNext()) { if (shareText.length() > 0) { shareText.append("\n\n"); } if (shareSubject.length() > 0) { shareSubject.append(", "); } shareSubject.append(c.getString(1)); shareText.append(c.getString(1)); if (!c.getString(2).isEmpty()) { shareText.append("\n").append(c.getString(2)); } } c.close(); } final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, shareText.toString()); shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubject.toString()); startActivity(shareIntent); } }); }
From source file:com.chummy.jezebel.material.dark.activities.Main.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.share: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = "Check out " + getResources().getString(R.string.theme_name) + " by " + getResources().getString(R.string.nicholas_short) + "!\n\nDownload it here!: " + getResources().getString(R.string.play_store_link); sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title)))); break;//from w w w . ja va 2 s .c o m case R.id.sendemail: StringBuilder emailBuilder = new StringBuilder(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + getResources().getString(R.string.email_id))); if (!isAppInstalled("org.cyanogenmod.theme.chooser")) { if (!isAppInstalled("com.cyngn.theme.chooser")) { if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); } else { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_rro)); } } else { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_cos)); } } else { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_cm)); } emailBuilder.append("\n \n \nOS Version: " + System.getProperty("os.version") + "(" + Build.VERSION.INCREMENTAL + ")"); emailBuilder.append("\nOS API Level: " + Build.VERSION.SDK_INT + " (" + Build.VERSION.RELEASE + ") " + "[" + Build.ID + "]"); emailBuilder.append("\nDevice: " + Build.DEVICE); emailBuilder.append("\nManufacturer: " + Build.MANUFACTURER); emailBuilder.append("\nModel (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")"); if (!isAppInstalled("org.cyanogenmod.theme.chooser")) { if (!isAppInstalled("com.cyngn.theme.chooser")) { if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) { emailBuilder.append("\nTheme Engine: Not Available"); } else { emailBuilder.append("\nTheme Engine: Layers Manager (RRO)"); } } else { emailBuilder.append("\nTheme Engine: Cyanogen OS Theme Engine"); } } else { emailBuilder.append("\nTheme Engine: CyanogenMod Theme Engine"); } PackageInfo appInfo = null; try { appInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } emailBuilder.append("\nApp Version Name: " + appInfo.versionName); emailBuilder.append("\nApp Version Code: " + appInfo.versionCode); intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString()); startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title)))); break; case R.id.changelog: changelog(); break; case R.id.hide_launcher: boolean checked = item.isChecked(); if (!checked) { new MaterialDialog.Builder(this).title(R.string.warning).content(R.string.hide_action) .positiveText(R.string.nice).show(); } item.setChecked(!checked); setLauncherIconEnabled(checked); return true; default: return super.onOptionsItemSelected(item); } return true; }
From source file:com.almarsoft.GroundhogReader.MessageActivity.java
private void forwardMessage() { String forwardMsg = "\n\n\nForwarded message originally written by " + mHeader.getField("From").getBody().trim() + " on the newsgroup [" + mGroup + "]: \n\n" + mOriginalText;// w ww .j a va 2 s . co m Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_TEXT, forwardMsg); i.putExtra(Intent.EXTRA_SUBJECT, "FWD: " + mSubjectText); i.setType("message/rfc822"); startActivity(Intent.createChooser(i, "Title:")); }
From source file:com.anjalimacwan.fragment.NoteEditFragment.java
public void dispatchKeyShortcutEvent(int keyCode) { switch (keyCode) { // CTRL+S: Save case KeyEvent.KEYCODE_S: // Set current note contents to a String contents = noteContents.getText().toString(); // If EditText is empty, show toast informing user to enter some text if (contents.equals("")) showToast(R.string.empty_note); else {// w ww .ja v a 2 s. co m try { // Keyboard shortcut just saves the note; no dialog shown saveNote(); isSavedNote = true; // Change window title String title; try { title = listener.loadNoteTitle(filename); } catch (IOException e) { title = getResources().getString(R.string.edit_note); } getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, ContextCompat.getColor(getActivity(), R.color.primary)); getActivity().setTaskDescription(taskDescription); } } catch (IOException e) { // Show error message as toast if file fails to save showToast(R.string.failed_to_save); } } break; // CTRL+D: Delete case KeyEvent.KEYCODE_D: listener.showDeleteDialog(); break; // CTRL+H: Share case KeyEvent.KEYCODE_H: // Set current note contents to a String contents = noteContents.getText().toString(); // If EditText is empty, show toast informing user to enter some text if (contents.equals("")) showToast(R.string.empty_note); else { // Send a share intent Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, contents); shareIntent.setType("text/plain"); // Verify that the intent will resolve to an activity, and send if (shareIntent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); } break; } }
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
private boolean sendEmail(String body, String subject, String userEmail) { userEmail = findAccount(userEmail);// ww w. j av a 2s. c o m Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { userEmail }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); emailIntent.setType("plain/text"); try { startActivity(emailIntent); return true; } catch (ActivityNotFoundException anf) { Log.i(PacoConstants.TAG, "No email client configured"); return false; } }