This question already has an answer here:
- Open Facebook page from Android app? 22 answers
I would like to open my Facebook page from my Android app, if the Facebook app is available - if not: this page should be open in the default browser.
for this i tried the following code:
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/MY_PAGE_ID"));
startActivity(intent);
} catch (Exception e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/MY_PAGE_NAME")));
}
Problem is: I have here an Android device with the newest version of Facebook. If I would like to open from my app the Facebook page, the Facebook app will open , but without my page.
I only see the message:
Trouble Loading Timeline.
What is wrong?
you can use this:
attention: you can get scoped user id from "link" permission facebook api
I already have answered here and it's working for me, please refer this link https://stackoverflow.com/a/40133225/3636561
please refer link to get rest part.
"fb://page/
does not work with newer versions of the FB app. You should usefb://facewebmodal/f?href=
for newer versions.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.
This works on the latest version:
Go to https://graph.facebook.com/ (https://graph.facebook.com/fsintents for instance).
Copy your id Use this method:
Okay I modifed @AndroidMechanics Code, because on devices were facebook is disabled the app crashes!
here is the modifed getFacebookUrl:
The only added thing is to look if the app is disabled or not if it is disabled the app will call the webbrowser!
Here's a solution that mixes the code by Jared Rummler and AndroidMechanic.
Note:
fb://facewebmodal/f?href=
redirects to a weird facebook page that doesn't have the like and other important buttons, which is why I tryfb://page/
. It works fine with the current Facebook version (126.0.0.21.77, June 1st 2017). The catch might be useless, I left it just in case.Here's the
appInstalledOrNot
function which I took (and modified) from Aerrow's answer to this postHow to get the Facebook ID of a page:
View Page Source
fb://page/?id=