Share Facebook with Facebook

I want to open a Facebook link from my Android app. The URL looks like http://www.facebbok.com/abcxyz . It should open the "abcxyz" page in the Facebook application, but it always opens in the browser.

Code:

try { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); activityContext.startActivity(browserIntent); } catch (ActivityNotFoundException ex) { ex.printStackTrace(); } 

My version is Android 6.0.1.

I have the same problem with Instagram, http://www.instagram.com/abcxyz , while other apps like Youtube work.

+6
source share
1 answer

You must use the facebook custom url scheme to force the application to open your page as shown below:

 public Intent getFacebookIntent(String url) { PackageManager pm = context.getPackageManager(); Uri uri = Uri.parse(url); try { ApplicationInfo applicationInfo = pm.getApplicationInfo("com.facebook.katana", 0); if (applicationInfo.enabled) { uri = Uri.parse("fb://facewebmodal/f?href=" + url); } } catch (PackageManager.NameNotFoundException ignored) { } return new Intent(Intent.ACTION_VIEW, uri); } 
+7
source

All Articles