It seemed a foregone question and I thought I could easily find an answer already, but the answers I found are very old and they do not work. How do I create a intent from my app to facebook page? I would like that if there is open the Facebook app, otherwise the browser
Up to now the best SOLUTION is that of Rishav Singla:
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>"));
}
}
use:
startActivity(getOpenFacebookIntent(getApplicationContext()));
... in attesa di altre soluzioni