I'm completely new to Java programming but I have to implement the following share for Facebook Messenger Expression Apps, my issue right now is that I don't know how to get an image from my drawable. How could it be done?
This code triggers on a onclick of a button. The image is on my drawable its called img.png
public void CompartirWhatsApp(View view) {
FacebookSdk.sdkInitialize(getApplicationContext());
String mimeType = "image/png";
String route = "drawable://" + R.drawable.img;;
File file = new File(route);
Uri contentUri = Uri.fromFile(file);
// contentUri points to the content being shared to Messenger
ShareToMessengerParams shareToMessengerParams =
ShareToMessengerParams.newBuilder(contentUri, mimeType)
.build();
// Sharing from an Activity
MessengerUtils.shareToMessenger(
this,
SHARE_TO_MESSENGER_REQUEST_CODE,
shareToMessengerParams);
}