Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:09:38+00:00 2026-06-17T18:09:38+00:00

Simply want to share a dynamic text string + the URL to the app.

  • 0

Simply want to share a dynamic text string + the URL to the app. The native Android share intent is setup correctly, and works perfect with Twitter, Gmail, etc. But, as many will guess, it does not work with Facebook. Appearantly because Facebook will not accept text in the intent.EXTRA_TEXT field, only a single URL.

Well, my question to y’all is: is there a way to branch off the share intent extras depending on which method they choose to share? for example, if they share via gmail or Twitter, use the existing String + URL (the desired option) EXTRA_TEXT, but if they choose to share via Facebook, only use a URL as the EXTRA_TEXT.

Not really wanting to implement the Facebook Android SDK for such a simple task that is built-in natively in Android.

Appreciate your time and advice.

Tried something like this, but it obviously fails because its only checking if the sharing option exists (when share pops up, not after they click a share method), it doesn’t respond when they choose a method.

  String shareBody = "app string text " + act_txt + " more text! Get the app at http://www.appurl.com";

 PackageManager pm = view.getContext().getPackageManager();
    List<ResolveInfo> activityList = pm.queryIntentActivities(sharingIntent, 0);
    for(final ResolveInfo app : activityList) {
         Log.i(TAG, "app.actinfo.name: " + app.activityInfo.name);
        //if((app.activityInfo.name).contains("facebook")) {
              if("com.facebook.katana.ShareLinkActivity".equals(app.activityInfo.name)) {


            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http://www.appurl.com");
            startActivity(Intent.createChooser(sharingIntent, "Share idea"));
            break;
        } else {
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "app name");
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
            startActivity(Intent.createChooser(sharingIntent, "Share"));
            break;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:09:40+00:00Added an answer on June 17, 2026 at 6:09 pm

    found a solution, on this SO question asking for something else: https://stackoverflow.com/a/8550043/1938669

    the attempt posted my original question here was close. within that cycle of possible shareIntent List, you need to create a new share intent targeted at the specific sharing choice (like facebook or twitter)

    here is a final working solution that shares only a URL if facebook is choosen, otherwise shares the complete text string + url:

    public void shareIt(View view){
        //sharing implementation
        List<Intent> targetedShareIntents = new ArrayList<Intent>();
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = "string of text " + txt_var + " more text! Get the app at http://someapp.com";
    
        PackageManager pm = view.getContext().getPackageManager();
        List<ResolveInfo> activityList = pm.queryIntentActivities(sharingIntent, 0);
        for(final ResolveInfo app : activityList) {
    
             String packageName = app.activityInfo.packageName;
             Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
             targetedShareIntent.setType("text/plain");
             targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "share");
             if(TextUtils.equals(packageName, "com.facebook.katana")){
                 targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http://someurl.com");
             } else {
                 targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
             }
    
             targetedShareIntent.setPackage(packageName);
             targetedShareIntents.add(targetedShareIntent);
    
        }
    
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Share Idea");
    
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
        startActivity(chooserIntent);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I simply want to edit some commits with git rebase -i HEAD~2 inside the
I simply want to popup an Alertbox in AS3. I am using Flashdevelop and
I simply want to post an image and comment from my own site to
I simply want to fill-up cells in my spreadsheet from a VBA function. By
I simply want to show off a model in a table that is paginated
I simply want to change a variable of an object from another class. I
I simply want to generate a class with attributes that comes from a Database
I simply want to return all rows from a users table but selected fields,
I have several sql queries that I simply want to fire at the database.
I'm working with various XML inputs and outputs and simply want to grab the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.