如何仅从android messenge应用程序

时间:2017-01-26 02:51:13

标签: java android api sdk messenger

请我是Android的新手,我一直在以Messenger的方式开发一个应用程序(研究并试图理解代码等),其中包括向朋友发送消息在脸书上 。因此,消息被发送,它包含一张图片。我的问题是如何只发送消息

到目前为止,我的代码是执行发送的活动部分:  `private void onMessengerButtonClicked(){

    Uri uri = Uri.parse("android.resource://inboxapp.example.com.inboxapp/" + R.drawable.cover);

    // Create the parameters for what we want to send to Messenger.
    ShareToMessengerParams shareToMessengerParams =
            ShareToMessengerParams.newBuilder(uri, "image/jpeg")
                    .setMetaData("{ \"image\" : \"tree\" }")
                    .build();

    if (mPicking) {
        // If we were launched from Messenger, we call MessengerUtils.finishShareToMessenger to return
        // the content to Messenger.
        MessengerUtils.finishShareToMessenger(this, shareToMessengerParams);
    } else {
        // Otherwise, we were launched directly (for example, user clicked the launcher icon). We
        // initiate the broadcast flow in Messenger. If Messenger is not installed or Messenger needs
        // to be upgraded, this will direct the user to the play store.
        MessengerUtils.shareToMessenger(
                this,
                REQUEST_CODE_SHARE_TO_MESSENGER,
                shareToMessengerParams);
    }
}`

请我坚持到那个级别,我看到SDK 4.x不再允许这个,是否有可能的解决方法?

谢谢

1 个答案:

答案 0 :(得分:0)

您是否尝试过置空或将其留空

传递图像的空值。

ShareToMessengerParams shareToMessengerParams =
        ShareToMessengerParams.newBuilder(uri, "null")
                .setMetaData("{ \"image\" : \"tree\" }")
                .build();

传递图像的空值。

ShareToMessengerParams shareToMessengerParams =
        ShareToMessengerParams.newBuilder(uri, "")
                .setMetaData("{ \"image\" : \"tree\" }")
                .build();