0

So I know the Facebook-app supports the fb:// URL scheme. But does it also support a URL scheme for HTTP?

I've tried for instance https://www.facebook.com/Google, and it does not yield an option to open the app, when clicked on from Chrome on an HTC One M8 device. So obviously Facebook haven't defined a URL scheme to match that URL. But they might have created others? Theoretically they could for instance have a scheme that triggered when a sub-url contains /app or something.

My goal is to link to a Facebook profile page which opens in the app if it is installed, and in the browser if not. Without using any Javascript. If facebook have defined a schema matching any HTTP-protocol, it is possible.

Community
  • 1
  • 1
Nilzor
  • 18,082
  • 22
  • 100
  • 167

2 Answers2

2

I made this work for link to google play with this function, changing te protocol to the facebook could work

public void getpro(View view) {
    final String appName = BuildConfig.APPLICATION_ID;
    try {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName")));
    } catch (android.content.ActivityNotFoundException anfe) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+appName")));
    }
}

to:

public void getpro(View view) {
    try {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("facebook://facebook.com/inbox")));
    } catch (android.content.ActivityNotFoundException anfe) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com")));
    }
}
Armando SM
  • 142
  • 5
0

You can try to achieve this with Intents. I found this:

String uri = "facebook://facebook.com/inbox";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);

Intent is used to call other applications while using an application.

Officer Bacon
  • 724
  • 1
  • 7
  • 22