1
String url  ="https://m.facebook.com/messages/read/?fbid=101631428274763";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);

I want to directly send some messages. This way I am able to send message to fb page...but, not able to add some texts to text field. So, how can I send messages? I know that I can do that by intent.putExtra but, what the name would be?

Man
  • 17
  • 6

2 Answers2

0

Here is You sent a message direct to FB messenger.

Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, "My message to send");
    sendIntent.setType("text/plain");
    sendIntent.setPackage("com.facebook.orca");

    try {
        startActivity(sendIntent);
    } catch (android.content.ActivityNotFoundException ex) {
        ToastHelper.show(this, "Please Install Facebook Messenger");
    }
Anwar Zahid
  • 227
  • 3
  • 10
  • Look at my url properly `101631428274763`.. I am sending message to a page... But, in your source code I am just sending message not to specific page or id... But, I want to specify that... – Man Mar 30 '21 at 15:42
0

Following source code worked properly for me

Uri uri = Uri.parse("fb-messenger://user/101631428274763");

    Intent toMessenger= new Intent(Intent.ACTION_VIEW, uri);
    toMessenger.putExtra(Intent.EXTRA_TEXT, "My message to send");
    try {
        startActivity(toMessenger);
    }
    catch (android.content.ActivityNotFoundException ex)
    {
        Toast.makeText(this, "Please Install Facebook Messenger",    Toast.LENGTH_LONG).show();
    }
Man
  • 17
  • 6