from my Android app, I would like to open a link to a Facebook profile in the official Facebook app (if the app is installed, of course). For iPhone, there exists the fb://
URL scheme, but trying the same thing on my Android device throws an ActivityNotFoundException
.
Is there a chance to open a Facebook profile in the official Facebook app from code?
A more reusable approach.
This is a functionality we generally use in most of our apps. Hence here is a reusable piece of code to achieve this.
(Similar to other answers in terms for facts. Posting it here just to simplify and make the implementation reusable)
"fb://page/
does not work with newer versions of the FB app. You should usefb://facewebmodal/f?href=
for newer versions. (Like mentioned in another answer here)This is a full fledged working code currently live in one of my apps:
This method will return the correct url for app if installed or web url if app is not installed.
Then start an intent as follows:
That's all you need.
try this code:
In Facebook version 11.0.0.11.23 (3002850)
fb://profile/
andfb://page/
no longer work. I decompiled the Facebook app and found that you can usefb://facewebmodal/f?href=[YOUR_FACEBOOK_PAGE]
. Here is the method I have been using in production:After much testing I have found one of the most effective solutions:
Best answer I have found, it's working great.
Just go to your page on Facebook in the browser, right click, and click on "View source code", then find the
page_id
attribute: you have to usepage_id
here in this line after the last back-slash:For example:
As of July 2018 this works perfectly with or without the Facebook app on all the devices.