在我的Android应用程序中,我想在Facebook官方应用程序中打开一个指向Facebook个人资料的链接(当然,如果安装了该应用程序的话).对于iPhone,存在fb://
URL方案,但在我的Android设备上try 同样的方法会抛出ActivityNotFoundException
.
是否有机会从code在Facebook官方应用程序中打开Facebook个人资料?
在我的Android应用程序中,我想在Facebook官方应用程序中打开一个指向Facebook个人资料的链接(当然,如果安装了该应用程序的话).对于iPhone,存在fb://
URL方案,但在我的Android设备上try 同样的方法会抛出ActivityNotFoundException
.
是否有机会从code在Facebook官方应用程序中打开Facebook个人资料?
在facebook版本11.0.0.11.23(3002850)fb://profile/
和fb://page/
中不再工作.我反编译了Facebook应用程序,发现您可以使用fb://facewebmodal/f?href=[YOUR_FACEBOOK_PAGE]
.以下是我在生产中一直使用的方法:
/**
* <p>Intent to open the official Facebook app. If the Facebook app is not installed then the
* default web browser will be used.</p>
*
* <p>Example usage:</p>
*
* {@code newFacebookIntent(ctx.getPackageManager(), "https://www.facebook.com/JRummyApps");}
*
* @param pm
* The {@link PackageManager}. You can find this class through {@link
* Context#getPackageManager()}.
* @param url
* The full URL to the Facebook page or profile.
* @return An intent that will open the Facebook page/profile.
*/
public static Intent newFacebookIntent(PackageManager pm, String url) {
Uri uri = Uri.parse(url);
try {
ApplicationInfo applicationInfo = pm.getApplicationInfo("com.facebook.katana", 0);
if (applicationInfo.enabled) {
// http://stackoverflow.com/a/24547437/1048340
uri = Uri.parse("fb://facewebmodal/f?href=" + url);
}
} catch (PackageManager.NameNotFoundException ignored) {
}
return new Intent(Intent.ACTION_VIEW, uri);
}