2
votes

I'm using Facebook SDK 4.2 to send a file (specifically, I'm exporting a serialized object) via Facebook Messenger for Android.

However, everyone only mentions images, audio and videos. Even the docs don't mention "text/plain" as supported MIME type.

Out of curosity I decided to try sharing file using "image/jpeg" and it worked. File is sent and the messenger allows to download it, but I don't think this is the accurate way. It feels like it will start to crash the app after some update. How to perform this action properly?

private void share(){
    File file = getMyFileMethod();
    Uri uri = Uri.fromFile(file);
    String mime_type = "image/jpeg";

    ShareToMessengerParams stmp = ShareToMessengerParams.newBuilder(uri, mime_type).build();
    MessengerUtils.shareToMessenger(this, 0, stmp);
}
1

1 Answers

0
votes

One possible way I can think of is create a bitmap out of the text data and then send it as an actual jpeg.