from my Android app, I would like to open a link to a Facebook profile in the official Facebook app (if the app is installed, of course). For iPhone, there exists the
open fb on button click event without using facebook sdk
Intent FBIntent = new Intent(Intent.ACTION_SEND);
FBIntent.setType("text/plain");
FBIntent.setPackage("com.facebook.katana");
FBIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
try {
context.startActivity(FBIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(context, "Facebook have not been installed.", Toast.LENGTH_SHORT).show( );
}
For Facebook page:
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + pageId));
} catch (Exception e) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + pageId));
}
For Facebook profile:
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + profileId));
} catch (Exception e) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + profileId));
}
...because none of the answers points out the difference
Both tested with Facebook v.27.0.0.24.15 and Android 5.0.1 on Nexus 4