2

My question is directly connected with this one Open Facebook page from Android app? Which answer (for the version at the moment) is not the marked one but this one

public static Intent newFacebookIntent(PackageManager pm, String url) {
Uri uri;
try {
    pm.getPackageInfo("com.facebook.katana", 0);
    // https://stackoverflow.com/a/24547437/1048340
    uri = Uri.parse("fb://facewebmodal/f?href=" + url);
} catch (PackageManager.NameNotFoundException e) {
    uri = Uri.parse(url);
}
return new Intent(Intent.ACTION_VIEW, uri);
}

Which is confirmed working last on 7th of February 2015.

My question is should you use the whole url (like www.facebook.com/mypage) or just add the url of the page so it'll be fb://facewebmodal/f?href=mypage. I tried both and it just opens the fb app without an actual page. It shows blank fb page on both tries.

Can someone give me an example with url for some public page that works?

Community
  • 1
  • 1
chnging
  • 746
  • 1
  • 8
  • 27
  • Check the next [question](http://stackoverflow.com/questions/11327799/open-page-in-facebook-twitter-and-google-plus-app-from-other-app-android/11328901#11328901), maybe it will help you – Ofir A. Mar 24 '15 at 19:20
  • Hi. Thank you but it didn't. It says "The content not available". Tried several pages. – chnging Mar 24 '15 at 21:37

5 Answers5

3

You can try to write mypage as https://www.facebook.com/ID. The whole uri should then be

fb://facewebmodal/f?href=https://www.facebook.com/ID

and change ID to the page you want to visit.

2

That functionality is not documented or supported, so you may get unknown result. You may want to try passing the Page ID or Profile ID instead of names. You can get the ID by calling https://graph.facebook.com/<name> and parse the result.

amudi
  • 136
  • 5
  • 1
    I'm trying your suggestion but hitting `An access token is required to request this resource.`? – Isaac Jan 23 '19 at 01:49
1

I had the same issue. I searched for a while and tried all the answers on here Open facebook page from android app (in facebook version > v11) and there Open Facebook page from Android app?, finally I figured out what the real problem is. There is nothing wrong in the code, however the weird behavior is about facebook app itself. If the facebook app is on the background, it just switches back to the foreground without navigating to the requested page. You just swipe it out from the background (kill instances) and try your code again.

Considering most of the users leave facebook app on the background, this is some kind of an issue needs to be fixed. Although I think it is about the facebook app itself, somehow it can be related with the device. I'm using Nexus 6 with v 6.0.1 and had no chance to test it on another android versioned device.

Community
  • 1
  • 1
Merve Gencer
  • 87
  • 1
  • 5
0

i using this for my apps its working just fine, kotlin

try {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/100674618166286"));
    startActivity(intent);
} catch(e: Exception) {
    startActivity( Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/iqtousd")));
}
-1

Remember have a similar issue.

Try the mobile url :

instead of

String facebookUrl = "https://facebook.com/...";

use

String facebookUrl = "https://m.facebook.com/...";
Tobliug
  • 2,992
  • 30
  • 28