如何与android studio messenger SDK共享

时间:2018-04-04 23:58:19

标签: android sdk messenger

我尝试与the android studio messenger SDK分享,但我真的不明白它是如何运作的。

我有我的Messenger应用程序ID,并在我的清单中设置,用maven安装了SDK。

我在" messenger_button_send_blue_round.xml"中添加了我的按钮。

我的代码来自教程:

ShareToMessengerParams shareToMessengerParams =
    ShareToMessengerParams.newBuilder(contentUri, "image/jpeg")
        .setMetaData("{ \"image\" : \"trees\" }")
        .build();

if (mPicking) {
    MessengerUtils.finishShareToMessenger(this, shareToMessengerParams);
} else {  
    MessengerUtils.shareToMessenger(
        this,
        REQUEST_CODE_SHARE_TO_MESSENGER,
        shareToMessengerParams);
}

我现在有两个问题:

1)REQUEST_CODE_SHARE_TO_MESSENGER始终为红色,我必须将其更改为" 1"。

2)如何将按钮单击链接到此代码?

1 个答案:

答案 0 :(得分:0)

这是我的代码用于在Messenger上共享(到目前为止在产品方面运行良好):

public void shareOnMessenger (SbElem sbElem) {
    // COPY TEMP FILE FROM LOCAL APP TO PUBLIC FOLDER
    final String newPath = getNewPathFromSbElem(sbElem);
    final File newFile = new File(newPath);
    final Uri newUri = FileProvider.getUriForFile(this, getString(R.string.file_provider_authority), newFile);
    // HAD TO SET IT TO 1, CAN'T FIND THE PUBLIC NAME ??
    final Integer SHARE_TO_MESSENGER_REQUEST_CODE = 1;

    String mimeType = "audio/*";
    ShareToMessengerParams shareToMessengerParams = ShareToMessengerParams.newBuilder(newUri, mimeType).build();
    MessengerUtils.shareToMessenger(this, SHARE_TO_MESSENGER_REQUEST_CODE, shareToMessengerParams);
}