Search This Blog

Wednesday 20 March 2013

open a facebook page on browser in android


Open a facebook page in Android Application

To open a facebook page in your android application you can create the following method and call this method in a class derived from activity

This will run the facebook page of the user in a different activity window.

public static Intent getOpenFacebookIntent(Activity acty,String szUserId,String szUserName) {

           try {
               acty.getBaseContext().getPackageManager().getPackageInfo("com.facebook.katana", 0);
            return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + szUserId));
           } catch (Exception e) {
            return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + szUserName));
           }
        }


If you like the code please provide your feedback.

No comments:

Post a Comment