Open Facebook Messenger in Android
58,841
Solution 1
Go to someone's facebook profile. Right click on the profile picture and copy the link address. Paste it on a text editor and you will see the "referrer_profile_id" parameter at the end of the URL. It is the facebook ID of that user.
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://messaging/" + FbUserID));
startActivity(i);
Solution 2
You can simply open it like this without an FB ID
Intent intent= new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Hello");
intent.setType("text/plain");
intent.setPackage("com.facebook.orca");
try
{
startActivity(intent);
}
catch (ActivityNotFoundException ex)
{
Toast.makeText(this,
"Oups!Can't open Facebook messenger right now. Please try again later.",
Toast.LENGTH_SHORT).show();
}
Author by
asda sda
Updated on February 26, 2020Comments
-
asda sda over 4 years
I want to open facebook messenger by code. How I can get the facebook ID?? I have the facebook SDK on my app and I saved for every user the facebookId but is not the same as I need
Here is my method:
// Make sure the Facebook Messenger for Android client is installed boolean isFBInstalled = isAppInstalled("com.facebook.orca"); if (!isFBInstalled) { Toast.makeText(this,"Facebook messenger isn't installed. Please download the app first.", Toast.LENGTH_SHORT) .show(); } else { // Create the Intent Uri uri = Uri.parse("fb-messenger://user/"); uri = ContentUris.withAppendedId(uri,Long.valueOf(facebookIDhere); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(intent); } catch(Exception e) { Toast.makeText(this,"Oups!Can't open Facebook messenger right now. Please try again later.", Toast.LENGTH_SHORT) .show(); } } return;
-
asda sda about 8 yearsI want to open a message to a specific user. I have a list of users, so I want to open the facebook messenger chat for this user
-
kmchmk over 6 years@KonstantinKonopko Which part?