Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Facebook Intent to visit a certain Facebook page? [duplicate]

Possible Duplicate:
Open Facebook page from Android app?

Does the Android Facebook app have Intents that other apps can use to start the Facebook app and goto a specific page?

For example, when someone clicks a certain button in my app, I want them to be taken to Facebook to a specific company's public Facebook page. Starting a web browser activity for this is easy, but more than likely the user is not logged in the browser etc...

I was thinking it would be nice if I could instead use an Intent (if one exists...) to start up the Facebook app and take the user to the specific page in the app. That way the user is already logged in and can interact with the page, Like it, etc...

Does an Intent like this exist? If so, where would I find more information on it? I've been looking through Facebook's developer documentation but I'm not seeing anything about this.

like image 530
Jake Wilson Avatar asked Nov 22 '11 17:11

Jake Wilson


1 Answers

  1. Go to https://graph.facebook.com/<user_name_here> (https://graph.facebook.com/fsintents for instance)
  2. Copy your id
  3. Use this method:

    public static Intent getOpenFacebookIntent(Context context) {
    
       try {
        context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
        return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/<id_here>"));
       } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<user_name_here>"));
       }
    }
    

This will open the Facebook app if the user has it installed. Otherwise, it will open Facebook in the browser.

like image 147
joaomgcd Avatar answered Sep 23 '22 12:09

joaomgcd