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.becapps.easydownloader.ShareActivity.java
@SuppressLint("CutPasteId") @Override// w w w . j a v a 2s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Appirater.appLaunched(this); AppBrain.initApp(this); startAppAd.showAd(); // show the ad startAppAd.loadAd(); // load the next ad mContext = getBaseContext(); settings = getSharedPreferences(PREFS_NAME, 0); // Theme init Utils.themeInit(this); setContentView(R.layout.activity_share); showSizesInVideoList = settings.getBoolean("show_size_list", false); // Language init Utils.langInit(this); // loading views from the layout xml tv = (TextView) findViewById(R.id.textView1); progressBarD = (ProgressBar) findViewById(R.id.progressBarD); progressBarL = (ProgressBar) findViewById(R.id.progressBarL); String theme = settings.getString("choose_theme", "D"); if (theme.equals("D")) { progressBar1 = progressBarD; progressBarL.setVisibility(View.GONE); } else { progressBar1 = progressBarL; progressBarD.setVisibility(View.GONE); } imgView = (ImageView) findViewById(R.id.imgview); lv = (ListView) findViewById(R.id.list); // YTD update initialization updateInit(); // Get intent, action and MIME type Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { try { handleSendText(intent, action); Utils.logger("d", "handling ACTION_SEND", DEBUG_TAG); } catch (IOException e) { e.printStackTrace(); Log.e(DEBUG_TAG, "Error: " + e.getMessage(), e); } } } AdView adview = (AdView) findViewById(R.id.adView); AdRequest re = new AdRequest(); re.setTesting(true); adview.loadAd(re); if (Intent.ACTION_VIEW.equals(action)) { try { handleSendText(intent, action); Utils.logger("d", "handling ACTION_VIEW", DEBUG_TAG); } catch (IOException e) { e.printStackTrace(); Log.e(DEBUG_TAG, "Error: " + e.getMessage(), e); } } }
From source file:com.android.mail.browse.AttachmentActionHandler.java
public void shareAttachment() { if (mAttachment.contentUri == null) { return;/*from www.j av a2 s . c o m*/ } Intent intent = new Intent(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); final Uri uri = Utils.normalizeUri(mAttachment.contentUri); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType(Utils.normalizeMimeType(mAttachment.getContentType())); try { mContext.startActivity(intent); } catch (ActivityNotFoundException e) { // couldn't find activity for SEND intent LogUtils.e(LOG_TAG, "Couldn't find Activity for intent", e); } }
From source file:com.carlrice.reader.fragment.EntryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mEntriesIds != null) { Activity activity = getActivity(); switch (item.getItemId()) { case R.id.menu_star: { mFavorite = !mFavorite;//from w ww . java2s . c om if (mFavorite) { item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important); } else { item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important); } final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentValues values = new ContentValues(); values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0); ContentResolver cr = Application.context().getContentResolver(); cr.update(uri, values, null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }.start(); break; } case R.id.menu_share: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); if (cursor != null) { String link = cursor.getString(mLinkPos); if (link != null) { String title = cursor.getString(mTitlePos); startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } } break; } case R.id.menu_full_screen: { setImmersiveFullScreen(true); break; } case R.id.menu_copy_clipboard: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", link); clipboard.setPrimaryClip(clip); Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_SHORT).show(); break; } case R.id.menu_mark_as_unread: { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentResolver cr = Application.context().getContentResolver(); cr.update(uri, FeedData.getUnreadContentValues(), null, null); } }.start(); activity.finish(); break; } } } return true; }
From source file:com.code.android.vibevault.ShowDetailsScreen.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.nowPlaying: //Open playlist activity Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class); startActivity(i);/*w w w.ja va 2 s. c o m*/ break; case R.id.recentShows: Intent rs = new Intent(ShowDetailsScreen.this, RecentShowsScreen.class); startActivity(rs); break; case R.id.scrollableDialog: AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Help!"); View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null); ((TextView) v.findViewById(R.id.DialogText)).setText(R.string.show_details_screen_help); ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { } }); ad.setView(v); ad.show(); break; case R.id.emailLink: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Great show on archive.org: " + show.getArtistAndTitle()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey,\n\nYou should listen to " + show.getArtistAndTitle() + ". You can find it here: " + show.getShowURL() + "\n\nSent using VibeVault for Android."); startActivity(Intent.createChooser(emailIntent, "Send mail...")); break; case R.id.downloadShow: for (int j = 0; j < downloadLinks.size(); j++) { downloadLinks.get(j).setDownloadShow(show); dService.addSong(downloadLinks.get(j)); } break; default: break; } return true; }
From source file:com.VVTeam.ManHood.Fragment.HistogramFragment.java
private void initViews(View view) { parentLayout = (RelativeLayout) view.findViewById(R.id.fragment_histogram_parent_relative_layout); /*BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2;/* ww w . j ava 2s. co m*/ parentLayout.setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.histogram_bg, options)));*/ settingsRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_settings_relative_layout); markRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_mark_relative_layout); worldRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_world_relative); // worldRelative.setSelected(true); worldRelative.setBackgroundResource(R.drawable.cell_p); areaRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_area_relative); hoodRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_hood_relative); yourResultButton = (Button) view.findViewById(R.id.fragment_histogram_your_result_button); contentRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_content_relative); RelativeLayout shareRelative = (RelativeLayout) view .findViewById(R.id.fragment_histogram_share_button_relative); shareRelative.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub GoogleTracker.StarSendEvent(getActivity(), "ui_action", "user_action", "histogram_share"); Bitmap image = makeSnapshot(); File pictureFile = getOutputMediaFile(); try { FileOutputStream fos = new FileOutputStream(pictureFile); image.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close(); } catch (Exception e) { } // String pathofBmp = Images.Media.insertImage(getActivity().getContentResolver(), makeSnapshot(), "Man Hood App", null); // Uri bmpUri = Uri.parse(pathofBmp); Uri bmpUri = Uri.fromFile(pictureFile); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); emailIntent.setType("image/png"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Man Hood App"); getActivity().startActivity(emailIntent); } }); polarPlot = (PolarPlot) view.findViewById(R.id.polarPlot); thicknessHisto = (Histogram) view.findViewById(R.id.thicknessHisto); thicknessHisto.setOrientation(ORIENT.LEFT); thicknessHisto.setBackgroundColor(Color.TRANSPARENT); lengthHisto = (Histogram) view.findViewById(R.id.lengthHistogram); lengthHisto.setOrientation(ORIENT.RIGHT); lengthHisto.setBackgroundColor(Color.TRANSPARENT); girthHisto = (Histogram) view.findViewById(R.id.girthHistogram); girthHisto.setOrientation(ORIENT.BOTTOM); girthHisto.setBackgroundColor(Color.TRANSPARENT); lengthHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestLength(value)); setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID)); setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID)); // setSelection(false, lengthHisto, 0.0f); setSelection(true, lengthHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); girthHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestGirth(value)); setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID)); setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID)); // setSelection(false, girthHisto, 0.0f); setSelection(true, girthHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); thicknessHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestThickness(value)); setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID)); setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID)); // setSelection(false, thicknessHisto, 0.0f); setSelection(true, thicknessHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); textBoxTitleLabel = (TextView) view.findViewById(R.id.txtBoxTitle); textBoxTitleLabel.setText("AVERAGE"); layoutSubTitle = (LinearLayout) view.findViewById(R.id.layoutSubTitle); layoutSubTitle.setVisibility(View.INVISIBLE); textBoxSubtitleLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleLabel); textBoxSubtitleValueLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleValue); lengthSelectedLabel = (TextView) view.findViewById(R.id.txtlengthselected); lengthSelectedLabel.setText("50%"); lengthTOPLabel = (TextView) view.findViewById(R.id.lengthTOPLabel); girthSelectedLabel = (TextView) view.findViewById(R.id.txtgirthselected); girthSelectedLabel.setText("50%"); girthTOPLabel = (TextView) view.findViewById(R.id.girthTOPLabel); thicknessSelectedLabel = (TextView) view.findViewById(R.id.txtthicknessselected); thicknessSelectedLabel.setText("50%"); thinkestAtTOPLabel = (TextView) view.findViewById(R.id.thinkestAtTOPLabel); curvedSelectedLabel = (TextView) view.findViewById(R.id.txtcurvedselected); curvedSelectedLabel.setText("0"); girthTopLB = (TextView) view.findViewById(R.id.girthTop); girthMiddleLB = (TextView) view.findViewById(R.id.girthMiddle); girthBottomLB = (TextView) view.findViewById(R.id.girthBottom); thicknessTopLB = (TextView) view.findViewById(R.id.thicknessTop); thicknessMiddleLB = (TextView) view.findViewById(R.id.thicknessMiddle); thicknessBottomLB = (TextView) view.findViewById(R.id.thicknessBottom); lengthTopLB = (TextView) view.findViewById(R.id.lengthTop); lengthMiddleLB = (TextView) view.findViewById(R.id.lengthMiddle); lengthBottomLB = (TextView) view.findViewById(R.id.lengthBottom); settingsRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).openSettingsActivity(); } }); markRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).openCertificateActivity(); } }); worldRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRangeAll); updateRangeSwitch(); } }); areaRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRange200); updateRangeSwitch(); } }); hoodRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRange20); updateRangeSwitch(); } }); yourResultButton.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { youTouchDown(); } else if (event.getAction() == MotionEvent.ACTION_UP) { youTouchUp(); // final Handler handler = new Handler(); // handler.postDelayed(new Runnable() { // @Override // public void run() { // youTouchUp(); // } // }, 2000); } return true; } }); RequestManager.getInstance().checkUser(); /* in-app billing */ String base64EncodedPublicKey = LICENSE_KEY; // Create the helper, passing it our context and the public key to verify signatures with Log.d(TAG, "Creating IAB helper."); mHelper = new IabHelper(getActivity(), base64EncodedPublicKey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(true); // Start setup. This is asynchronous and the specified listener // will be called once setup completes. Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. Log.d(TAG, "Problem setting up in-app billing: " + result); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; // IAB is fully set up. Now, let's get an inventory of stuff we own. Log.d(TAG, "Setup successful. Querying inventory."); mHelper.queryInventoryAsync(mGotInventoryListener); } }); }
From source file:ch.dbrgn.android.simplerepost.activities.RepostActivity.java
private void createInstagramIntent(String type, String mediaPath, String caption) { // Create the new Intent using the 'Send' action. Intent share = new Intent(Intent.ACTION_SEND); // Set the MIME type share.setType(type);//from w w w . jav a 2 s . com // Create the URI from the media File media = new File(mediaPath); Uri uri = Uri.fromFile(media); // Add the URI and the caption to the Intent. share.putExtra(Intent.EXTRA_STREAM, uri); share.putExtra(Intent.EXTRA_TEXT, caption); // Broadcast the Intent. startActivity(Intent.createChooser(share, "Share to")); }
From source file:com.anysoftkeyboard.ui.dev.DeveloperToolsFragment.java
private void shareFile(File fileToShare, String title, String message) { Intent sendMail = new Intent(); sendMail.setAction(Intent.ACTION_SEND); sendMail.setType("plain/text"); sendMail.putExtra(Intent.EXTRA_SUBJECT, title); sendMail.putExtra(Intent.EXTRA_TEXT, message); if (fileToShare != null) { sendMail.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileToShare)); }//from w w w. ja va 2 s . c o m try { Intent sender = Intent.createChooser(sendMail, "Share"); sender.putExtra(Intent.EXTRA_SUBJECT, title); sender.putExtra(Intent.EXTRA_TEXT, message); startActivity(sender); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity().getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG).show(); } }
From source file:com.stepinmobile.fantasticbutton.api.ButtonHandle.java
/** * This method search in all applications, and if it will find one, which contains in package name parameter <b>type</b>, it will create share intent and return it. * In another case, if application wouldn't be found it will return null. * * @param type part of application package name * @param subject title, which would be applied to created share event * @param text content, which would be provided into share intent * @return created share intent or <b>null</b>, if application wouldn't be found *//*from w ww . j a v a 2 s . co m*/ private Intent getShareIntent(String type, String subject, String text) { boolean found = false; Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); // gets the list of intents that can be loaded. List<ResolveInfo> resInfo = ((Activity) aq.getContext()).getPackageManager().queryIntentActivities(share, 0); if (!resInfo.isEmpty()) { for (ResolveInfo info : resInfo) { if (info.activityInfo.packageName.toLowerCase().contains(type) || info.activityInfo.name.toLowerCase().contains(type)) { share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, text); share.setPackage(info.activityInfo.packageName); found = true; break; } } if (!found) return null; return share; } return null; }
From source file:com.architjn.materialicons.ui.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_sendemail) { StringBuilder emailBuilder = new StringBuilder(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + getResources().getString(R.string.email_id))); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(") .append(Build.VERSION.INCREMENTAL).append(")"); emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT); emailBuilder.append("\nDevice: ").append(Build.DEVICE); emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER); emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT) .append(")"); PackageInfo appInfo = null;/* w w w . j a va2s . com*/ try { appInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } assert appInfo != null; emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName); emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode); intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString()); startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title)))); return true; } else if (id == R.id.action_share) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = getResources().getString(R.string.share_one) + getResources().getString(R.string.developer_name) + getResources().getString(R.string.share_two) + MARKET_URL + getPackageName(); sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title)))); } else if (id == R.id.action_changelog) { showChangelog(); } return super.onOptionsItemSelected(item); }
From source file:com.code19.library.SystemUtils.java
public static void shareText(Context ctx, String title, String text) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); //intent.putExtra(Intent.EXTRA_SUBJECT, title); intent.putExtra(Intent.EXTRA_TEXT, text); ctx.startActivity(Intent.createChooser(intent, title)); /* List<ResolveInfo> ris = getShareTargets(ctx); if (ris != null && ris.size() > 0) { ctx.startActivity(Intent.createChooser(intent, title)); }*//*from w w w . ja va 2 s .c o m*/ }