与facebook Messenger共享文字?

Bol*_*aul 16 android facebook-messenger

有没有办法在Facebook Messenger中使用android和也许facebook sdk分享文本?

我想制作类似whatsapp的方式,选择你的文字并打开一个意图选择你要发送给的人...有没有办法用facebook messenger做到这一点?它出现在intent.choose对话框中..但我只想发送给facebook messenger ..

Dhi*_*asu 34

使用此代码onClick ,,

com.facebook.orca是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) {
        Toast.makeText(context,"Please Install Facebook Messenger", Toast.LENGTH_LONG).show();
    }
Run Code Online (Sandbox Code Playgroud)

  • 从2015年5月初开始,Messenger不再将自己注册为共享目标.在它改变之前,上面的代码将不起作用. (5认同)
  • 当您在 chrome 中共享文本时,Messenger 会显示在默认的系统共享选择器中,因此它肯定已被添加回来。 (2认同)

Nin*_*bli 17

与特定用户一起启动Facebook Messenger

Uri uri = Uri.parse("fb-messenger://user/"); uri = ContentUris.withAppendedId(uri,[provide user id]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);

它会启动你提到的用户ID的信使