分享与Facebook Messenger中的文字?文字、Facebook、Messenger

2023-09-07 04:27:05 作者:回忆不能淡忘

有没有办法使用机器人来分享到Facebook Messenger中的文字,也许Facebook的SDK中呢?

Is there a way to share a text in facebook messenger using android and maybe facebook sdk as well?

我想要的东西,如WhatsApp的方式,选择你的文字,打开的意图,选择要发送的家伙... 有没有一种方法来与Facebook Messenger的做到这一点? 它出现在intent.choose dialog..but我只想发送到Facebook的使者。

I want to make something like the whatsapp way, choose your text and open an intent to choose the guy you want to send to... Is there a way to do this with facebook messenger? It appears in the intent.choose dialog..but I only want to send to facebook messenger..

推荐答案

使用code的onClick ,,

use this code onClick,,

com.facebook.orca是FB信使包名称。

com.facebook.orca is the package name for fb messenger.

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent
            .putExtra(Intent.EXTRA_TEXT,
                    "<---YOUR TEXT HERE--->.");
    sendIntent.setType("text/plain");
    sendIntent.setPackage("com.facebook.orca");
try
{
    startActivity(sendIntent);
}
catch (android.content.ActivityNotFoundException ex) 
{
    ToastHelper.MakeShortText("Please Install Facebook Messenger");
}

编辑:

2015年开始五月初使者不再是自己注册为共享意向目标。直到它的变化,code以上将无法正常工作。

Beginning early May 2015 Messenger no longer register itself as share intent target. Until it changes, code above won't work.