如何仅从 android 消息应用程序发送消息

How to send only message from android messenge application

拜托,我是 Android 的新手,我已经开发了一个 Messenger 风格的应用程序一周(研究并试图理解代码......等等),其中包括发送消息致我在 Facebook 上的朋友。这样消息就发送出去了,里面包含了一张图片。我的问题是如何只发送消息

到目前为止,这是我的 activity 发送部分的代码: ` 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 不再允许这样做,是否没有可能的解决方法?

谢谢

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

正在为图像传递空值。

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

为图像传递空值。

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