1

I am using below code to open a facebook post's link using facebook app on android. The post opens, has a like button on top right(thumbs up icon), also it has a comment option at bottom. But share option is missing. Here is the code:

/**
     * Intent to open the official Facebook app. If the Facebook app is not installed then the
     * default web browser will be used.
     *
     * </br></br>Example usage:</br>
     * <code>newFacebookIntent(context.getPackageManager(), "https://www.facebook.com/JRummyApps");</code>
     *
     * @param pm
     *            Instance of the {@link PackageManager}.
     * @param url
     *            The full URL to the Facebook page or profile.
     * @return An intent that will open the Facebook page/profile.
     */
    public static Intent newFacebookIntent(PackageManager pm, String url) {
        Uri uri;
        try {
            pm.getPackageInfo("com.facebook.katana", 0);
            // https://stackoverflow.com/a/24547437/1048340
            uri = Uri.parse("fb://facewebmodal/f?href=" + url);
        } catch (PackageManager.NameNotFoundException e) {
            uri = Uri.parse(url);
        }
        return new Intent(Intent.ACTION_VIEW, uri);
    }

The source of above code is this SO answer. An example link is: https://www.facebook.com/unesco/photos/a.10150253911838390.341477.51626468389/10153252513313390/?type=1

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164

0 Answers0