1

I'm trying to open a facebook app, from my app, but i need it to go to specific user's timeline. I can open it in the phone browser it works fine, but i can't open it in facebook app... I know facebook changed the way it was before, i'm using facebook-android-sdk:4.6.0 This is my code:

public Intent getOpenFacebookIntent(String userId) {
        Log.e(TAG, "pid "+ userId);
        try {
            getPackageManager().getPackageInfo("com.facebook.katana", 0);
            return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + userId));

        } catch (Exception e) {
            return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + userId));

        }
    }

Thnx!

Gidi Sprintzin
  • 365
  • 1
  • 2
  • 15

2 Answers2

1

Just do a little change

"https://www.facebook.com/profile.php?id=" + userId

Try this one.

Also, FYI: https://www.facebook.com/" + userId will work only when you pass username not userId.

TheLittleNaruto
  • 8,325
  • 4
  • 54
  • 73
0

The only code that worked for me was:

public Intent getOpenFacebookIntent(String userId) {
        Log.e(TAG, "pid "+ userId);

        String facebookUrl = "https://www.facebook.com/"+userId;
        try {
            getPackageManager().getPackageInfo("com.facebook.katana", 0);

            return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=" + facebookUrl));

        } catch (Exception e) {
            return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/app_scoped_user_id/" + userId));

        }
    }
Gidi Sprintzin
  • 365
  • 1
  • 2
  • 15