How can I show a screenshot of the game through the native share menu?

Hey guys!
I’m trying to implement a feature in my game that the player has the option to share his score through his social media in the game over screen. I would like to programmatically take a screenshot of the screen, attach a custom message and display a share menu like the one in the picture below:

I’ve been playing around with the SDKBOX Social plugin, but I’m not sure it supports this feature. I would like to allow the user to choose whichever application they want to share their score on. Does anyone know if it’s possible to achieve such result with the SDKBOX plugin? Or is there another plugin that supports this feature?

Any help is appreciated! :slight_smile:

I think this has been answered, just last week :slight_smile:

plz read the doc

sdkbox::SocialShareInfo info;
info.text = "#sdkbox( - the cure for sdk fatigue ";
info.title = "sdkbox";
//info.image = "path/to/image" = "";

// the follow property will be ignored in nativeShare
//info.showDialog = false;
//info.platform = sdkbox::SocialPlatform::Platform_Select;


more info
<provider android:authorities="com.helloworld.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
<meta-data android:name="" android:resource="@xml/file_paths" />
before share()

Hi, yinjimmy,
When I implement share plugin, I got this error when sharing a image
error:android.os.FileUriExposedException: file:///data/user/0/com.helloworld/files/myimage.png exposed beyond app through ClipData.Item.getUri()
I saved image with following code
jsb.fileUtils.getWritablePath() + "render_to_sprite_image.png"
I checked file_paths.xml, found following lines
<external-path name="external_files" path="." />
<external-files-path name="my_images" path="Pictures" />
<external-files-path name="my_movies" path="Movies" />
I added line below
<files-path path="./" name="internal_files" />
but it still doesn’t work.
Would you pls help take a look? thank you.

how do you share the img ?


is not same as jsb.fileUtils.getWritablePath() + "render_to_sprite_image.png"

Thank you for reply.
It was
jsb.fileUtils.getWritablePath() + "myimage.png"
in my code.
I pasted wrong code here.
My share code is

export function share(aTitle: string, aContent?: string, aLink?: string, aImage?: string) {
const shareInfo = {
title: aTitle,
text: aContent ? aContent : “”,
link: aLink ? aLink : “”,
type: “”,
image: aImage ? aImage : null,
showDialog: true,
platform: 3,
const filePath = jsb.fileUtils.getWritablePath() + “myimage.png”;
jsb.saveImageData(picData, width, height, filePath);
share(“MyTitle”, “MyContent”, “”, filePath);

I also tried using external storage, added permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
and use following code.
I can see the screenshot has been saved to SD card root dir, but still got same share error.
The android OS is Android 8.1.0, multiDex, useAndroidX is enabled, using androidx.core.content.FileProvider not

        const filePath = "/mnt/sdcard/screenshot.png";
        const success = jsb.saveImageData(picData, width, height, filePath);
        if (success) {
            cc.log("save image data success, file: " + filePath);
            share("MyTitle", "MyContent", "", filePath);

thanks, we will look into this issue.