Where is the Android screenshot?

※I am Japanese, so I’m not good at English

I want to save screenshot in android photos application.
I’m using britzl screenshot.

It works on Windows platform, but it does not work on android.
ERROR(Android Debugging)

/main/game/game.gui_script:38: attempt to index global ‘screenshot’ (a nil value)

What should I do to put Defold screenshot into Android Photos app?

The extension should work on Android. How are you using it? You need to bundle a version of the APK. You can’t use dmengine.apk from d.defold.com since it doesn’t contain the native extension. You can bundle a debug variant and use that as a target in the project menu.

1 Like

Thanks for your reply!
I tried to use bundle APK. But I cannot found png image.
I want to save it into Photo App. How can I do this?

Once you have taken a screenshot you can save it as a file like this:

	local png, w, h = screenshot.png()
	local f = io.open("screenshot1.png", "wb")
	f:write(png)
	f:flush()
	f:close()

The problem is that you need to figure out a path to a folder that is accessible by the Photos app. @sergey.lerg has this extension that gives you paths to various system directories:

It does however not provide a path to any Pictures directory. I would suggest that you collaborate with @sergey.lerg to add this as a new path.

3 Likes

On Android the are several standard paths to the DCIM folder, but you need write external storage permission to access them.
But it’s all a bit tricky since Android devices are kinda unpredictable.

1 Like

Thanks!
I will try it :smiley: