Given the recent \"encouragement\" by Facebook to migrate to a separate messenger app, and as a followup to the {very informative!} answer to the question on URL/URI schemes
I know it is late but i hope it can help others
For my case i wanted to open my page messenger bubble if installed of course
So here what worked for me :
messengerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String messengerUrl ;
if (isMessengerAppInstalled()) {
Toast.makeText(ServiceClient.this, "messenger is installed , open app bubble", Toast.LENGTH_SHORT).show();
messengerUrl = "fb-messenger://user/475527699675914/";
} else {
Toast.makeText(ServiceClient.this, "messenger is not installed , open messenger in browser", Toast.LENGTH_SHORT).show();
messengerUrl = "https://www.messenger.com/t/475527699675914/";
}
Intent messengerIntent = new Intent(Intent.ACTION_VIEW);
messengerIntent.setData(Uri.parse(messengerUrl));
startActivity(messengerIntent);
}
});
public boolean isMessengerAppInstalled() {
try {
getApplicationContext().getPackageManager().getApplicationInfo("com.facebook.orca", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}