1

I'm struggling linking to a Facebook profile page when the Facebook app is installed. It says that the page is not available. When the facebook app is not installed (opening with browser), everything works fine. Any ideas?

public static Intent getFBIntent(Context context, String facebookId) {
        try {
            // Check if FB app is even installed
            context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
            String facebookScheme = "fb://profile/" + facebookId; //also tried with /page
            Log.d("FB_LINK", facebookScheme);
            return new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme));
        }
        catch(Exception e) {
            // Cache and Open a url in browser
            String facebookProfileUri = "https://www.facebook.com/" + facebookId;
            return new Intent(Intent.ACTION_VIEW, Uri.parse(facebookProfileUri));
        }
    }
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
Matthias
  • 35
  • 5

1 Answers1

0

try this

public static void openFacebookProfile(Context context,String userProfileLink) {
    Intent facebookIntent = null;

    try {
        //If facebook app is installed 
        facebookIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("fb://facewebmodal/f?href=" + userProfileLink));

    } catch (Exception e) {
        //Open in browser
        facebookIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(userProfileLink));
    }

    context.startActivity(facebookIntent);
}

you can get user profile link from graph api.