I'm having trouble accessing the facebook page (or app if it's installed) from within the app.
if (AboutPageUtils.isAppInstalled(mContext, "com.facebook.katana")) {
intent.setPackage("com.facebook.katana");
int versionCode = 0;
try {
versionCode = mContext.getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Uri uri;
if (versionCode >= 3002850) {
uri = Uri.parse("fb://facewebmodal/f?href=" "https://m.facebook.com/" id);
} else {
uri = Uri.parse("fb://page/" id);
}
intent.setData(uri);
} else {
intent.setData(Uri.parse("http://m.facebook.com/" id));
}
The code above worked before and now Facebook app showing 'Trouble Loading page.
CodePudding user response:
public static Intent getOpenFacebookIntent(Context context) {
try {
context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/<id_here>"));
} catch (Exception e) {
return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<user_name_here>"));
}
}