Opening facebook app on specified profile page

Is this not easier? For example within an onClickListener?

try { 
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/426253597411506"));
    startActivity(intent);
} catch(Exception e) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/appetizerandroid")));    
}   

PS. Get your id (the large number) from http://graph.facebook.com/[userName]


This no longer works

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/someProfile"));

Please try this instead

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=https://www.facebook.com/someProfile"));

Actually it looks like this. These URIs only work with the most recent version of the facebook app. That's why we try catch.

public static Intent getOpenFacebookIntent(Context context) {

    try {
        context.getPackageManager()
                .getPackageInfo("com.facebook.katana", 0); //Checks if FB is even installed.
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("fb://profile/254175194653125")); //Trys to make intent with FB's URI
    } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://www.facebook.com/arkverse")); //catches and opens a url to the desired page
    }
}

In your Activity, to open it, call it like so:

Intent facebookIntent = getOpenFacebookIntent(this);
startActivity(facebookIntent);