Share text via Intent on Facebook without using Facebook sdk

As Facebook doesn’t allow sharing text via Intent unless we use Facebook sdk, I am looking for a way around to achieve this.

I can think of 3 hacks which I can use:

  • How to display 2 views, with a gradient-fade effect on Android?
  • Android Studio build.gradle - Cannot resolve symbol 'android'
  • Download App from Google Play programatically
  • How to set a custom keystore for debugging in eclipse for android
  • how to convert long date value to mm/dd/yyyy format
  • Android In-app version check
  • 1) As Facebook allows image sharing, I can generate a Bitmap with sharing text drawn onto it and share the image using Intent.

    2) Facebook allows sharing URLs, for which it also displays the Head of the page while sharing. I can host a dedicated page on my server and pass values as parameter in the url, and generate the Head using it.(I have no experience with php, but I guess this is possible)

    3) Copy text to clipboard and notify user about this.

    OR

    Use combinations of all 3.

    Can anyone suggest me a much better way around to share my content on Facebook without using Facebook sdk?

    Thanks in advance.

    Related posts:

    How to call a method in activity from a service
    Android : Check 3G or Wifi network is ON or Available or not on android Device
    PopupWindow overlaps soft buttons on Android 5.0
    Convert time value to format “hh:mm Am/Pm” using Android
    Screen Video Record of Current Activity Android
    Android Spinner Toolbar style
  • java.lang.RuntimeException Theme.Sherlock
  • Equivalent of LocalBroadcastManager without Android support library
  • YouTubePlayerFragment inside ReyclerView
  • How to terminate android application while debugging in eclipse
  • How to programmatically insert call log entries WITH display name and photo?
  • custom row in a listPreference?
  • 7 Solutions collect form web for “Share text via Intent on Facebook without using Facebook sdk”

    There is no way you can share Text alone in the Facebook using android shareIntent.

    It is possible only through Facebook SDK using share links functions.

    Facebook simply ignores the Extra Text from the intent if there is an image. You can share image, but it does not allow you to share the Text content.

    Unfortunately the Facebook sharing intent can only take a single URL with prefixed http:// and no additional text message. Actually facebook strips out the text content and allows only URL/Link. It is by Design and we have no control over it.

    This will work

    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com");
    startActivity(Intent.createChooser(sharingIntent, "Share via"));
    

    This will not work.

    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(Intent.EXTRA_TEXT, "Share Text from App");
    startActivity(Intent.createChooser(sharingIntent, "Share via"));
    

    Only approach you can share the text in the Facebook is using Facebook
    SDK.

    Reference Links

    Android share intent for facebook- share text AND link

    Unable to share text with a link through Android Share Intent

    Android and Facebook share intent

    First of all, in order to share text on FB, you got to use FB SDK.

    Without FB SDK better option is to go for a dedicated website with “OG” data, which will get resolved automatically. By this, you can change your OG data when ever you need a change.

    I would suggest you to go for your hack number 2. But, with this approach, FB allows users to click on the link and redirects to the website, you may try to handle this according to your requirement.

    I hope you are clarified with this.

    For details on OG please check this Open Graph details

    This code lets you paste your content on only on facebook.
    what id do is get the list of all apps present in your phone and find the open then open facebook app if is already present

            Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text to be shared");
            PackageManager pm = getPackageManager();
            List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
            for (final ResolveInfo app : activityList) {
                if ((app.activityInfo.name).contains("facebook")) {
                    final ActivityInfo activity = app.activityInfo;
                    final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
                    shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                    shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                    shareIntent.setComponent(name);
                    startActivity(shareIntent);
                    break;
               }
            }
    

    Use this function, I hope it will help

    public static void share(Context context, String text, String subject, String title, String dialogHeaderText) {
        Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        intent.putExtra(android.content.Intent.EXTRA_TEXT, text);
        intent.putExtra(Intent.EXTRA_TITLE, title);
        context.startActivity(Intent.createChooser(intent, dialogHeaderText));
    }
    

    When you use native intent it’s up to the app the user shares with if it uses the data from the intent or not.

    This is a known bug and facebook have made this bug to wishlist. Maybe they are not trying to fix it. This is intentional to make people use FB SDK i think. refer this link http://forum.developers.facebook.net/viewtopic.php?id=93900 and this post

    http://forum.developers.facebook.net/viewtopic.php?id=93900

    Check this :

    Intent share=new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_TEXT, "Some text you would like to share...");
    share.setPackage("com.facebook.katana"); //Facebook App package
    startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));
    

    You don’t need facebook SDK with this code……

    To enhance your UX, you can do a check if Facebook App(or FacebookLite App) ware installed…

    If you don’t mind other sharing options being presented you can just use a regular sharing intent with a picker since Facebook will be one of the options to share if they have it enabled.

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
    shareIntent.setType("text/plain");
    startActivity(Intent.createChooser(shareIntent, "Choose sharing method"));
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.