Screen Capture not Saving to Phone

I’m trying to make a screenshot button so people can post their scores on the internet.  When I press the button it captures and make a copy to Corona Simulator folder. When I put it in my phone it seems like it’s not saving it to my phone.  Every time I try to edit my build.settings file my game get turn vertical. Please look at my build.settings to make sure its correct.

This is my build.settings:

[lua]

– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {
    
    orientation = {
        default = “landscapeRight”,
        supported = { “landscapeLeft”, “landscapeRight” },
    },
    
    iphone = {
        plist = {
            UIStatusBarHidden = false,
            UIPrerenderedIcon = true, – set to false for “shine” overlay
            --UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            --[[
            – iOS app URL schemes:
            CFBundleURLTypes =
            {
                {
                    CFBundleURLSchemes =
                    {
                        “fbXXXXXXXXXXXXXX”, – example scheme for facebook
                        “coronasdkapp”, – example second scheme
                    }
                }
            }
            --]]
        }
    },
    
    [[
     Android permissions

    androidPermissions = {
          “android.permission.INTERNET”,
        “android.permission.WRITE_EXTERNAL_STORAGE”,
        settings
{
    android =
    {
        versionCode = “11”,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.WRITE_EXTERNAL_STORAGE”,
      },

    ]]
}

[/lua]

This is what I use to capture:

[lua]

local function captureOnEvent()

    local screenBounds =
{
    xMin = 145,
    xMax = 335,
    yMin = 65,
    yMax = 250,
}

    local myCaptureImage = display.captureBounds( screenBounds, true )
    
    myCaptureImage:removeSelf()
    myCaptureImage = nil
  
    local alert = native.showAlert( “Success”, “Screen Capture Saved to Library”, { “OK” } )
    
end

[/lua]

What folder on the device is the captured image being save to? I have a Samsung s4 and I can’t locate it anywhere.

It will save to your app’s sandbox storage, (i.e. system.DocumentsDirectory) which you do not have access to outside of your app.

Rob

Is there any to take a sceenshot of the score and save it to the device gallery so the users can post it on their social network?

I really need help with this. This is the last step to my app so i can release it. Any help will be greatly appreciated.

Hi @unknown_pryde,

Which device are you testing this on? If an Android device, can you carefully check and clean up your build.settings according to the following guide? Meaning, get rid of any redundant tables, remove commented-out sections for readability, make sure that all tables are nested properly, etc.

http://docs.coronalabs.com/guide/distribution/buildSettings/index.html#androidsettings

Best regards,

Brent

This is my new build.settings.lua.  My screen capture button work, but I just can’t locate the picture anywhere when I put it on my Android Samsung S4. On the simulator when I click on the capture button, it capture the score and save the picture to the “Corona Simulator” folder under my “Pictures” folder. Is there any way I can make the screen capture save on to the device sd card?

settings = {

        plugins =
    {
        [“CoronaProvider.ads.admob”] =
        {
            publisherId = “com.coronalabs”
        },
    },      

    
    orientation = {
        default = “landscapeRight”,
        supported = { “landscapeLeft”, “landscapeRight” },
    },
    
    iphone = {
        plist = {
            UIStatusBarHidden = false,
            UIPrerenderedIcon = true,
            
        }
    },
    
    [[
     Android permissions

    androidPermissions = {
          “android.permission.INTERNET”,
        “android.permission.WRITE_EXTERNAL_STORAGE”,
        “android.permission.ACCESS_NETWORK_STATE”,
        settings
{
    android =
    {
        versionCode = “11”,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.WRITE_EXTERNAL_STORAGE”,
            “android.permission.ACCESS_NETWORK_STATE”,
      },

    ]]
}

Hi @unknown_pryde,

What are these in your code?

[[]]

Are you trying to comment out some code with this?

--[[--]]

The structure should probably look more like the following… not necessarily with all of these permissions and features, but something along this layout:

[lua]

settings

{

    android =

    {

        versionCode = “11”,

        usesPermissions =

        {

            “android.permission.INTERNET”,

            “android.permission.WRITE_EXTERNAL_STORAGE”,

            “android.permission.ACCESS_NETWORK_STATE”,

        },

        usesFeatures =

        {

            { name=“android.hardware.camera”, required=true },

        },

    },

}

[/lua]

I don’t know how [[ ]] got there. But good news thanks to you Brent Sorrentino. I was able to get the capture button to save the photo in the gallery of my device by removing [[ ]].

Here is my new build.settings.

settings = {

        plugins =
    {
        [“CoronaProvider.ads.admob”] =
        {
            publisherId = “com.coronalabs”
        },
    },      

    
    orientation = {
        default = “landscapeRight”,
        supported = { “landscapeLeft”, “landscapeRight” },
    },
    
    
     --Android permissions

    android =
    {
        versionCode = “11”,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.WRITE_EXTERNAL_STORAGE”,
            “android.permission.ACCESS_NETWORK_STATE”,
        },
 
        usesFeatures =
        {
            { name=“android.hardware.camera”, required=true },
        },
 
    },
}

What folder on the device is the captured image being save to? I have a Samsung s4 and I can’t locate it anywhere.

It will save to your app’s sandbox storage, (i.e. system.DocumentsDirectory) which you do not have access to outside of your app.

Rob

Is there any to take a sceenshot of the score and save it to the device gallery so the users can post it on their social network?

I really need help with this. This is the last step to my app so i can release it. Any help will be greatly appreciated.

Hi @unknown_pryde,

Which device are you testing this on? If an Android device, can you carefully check and clean up your build.settings according to the following guide? Meaning, get rid of any redundant tables, remove commented-out sections for readability, make sure that all tables are nested properly, etc.

http://docs.coronalabs.com/guide/distribution/buildSettings/index.html#androidsettings

Best regards,

Brent

This is my new build.settings.lua.  My screen capture button work, but I just can’t locate the picture anywhere when I put it on my Android Samsung S4. On the simulator when I click on the capture button, it capture the score and save the picture to the “Corona Simulator” folder under my “Pictures” folder. Is there any way I can make the screen capture save on to the device sd card?

settings = {

        plugins =
    {
        [“CoronaProvider.ads.admob”] =
        {
            publisherId = “com.coronalabs”
        },
    },      

    
    orientation = {
        default = “landscapeRight”,
        supported = { “landscapeLeft”, “landscapeRight” },
    },
    
    iphone = {
        plist = {
            UIStatusBarHidden = false,
            UIPrerenderedIcon = true,
            
        }
    },
    
    [[
     Android permissions

    androidPermissions = {
          “android.permission.INTERNET”,
        “android.permission.WRITE_EXTERNAL_STORAGE”,
        “android.permission.ACCESS_NETWORK_STATE”,
        settings
{
    android =
    {
        versionCode = “11”,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.WRITE_EXTERNAL_STORAGE”,
            “android.permission.ACCESS_NETWORK_STATE”,
      },

    ]]
}

Hi @unknown_pryde,

What are these in your code?

[[]]

Are you trying to comment out some code with this?

--[[--]]

The structure should probably look more like the following… not necessarily with all of these permissions and features, but something along this layout:

[lua]

settings

{

    android =

    {

        versionCode = “11”,

        usesPermissions =

        {

            “android.permission.INTERNET”,

            “android.permission.WRITE_EXTERNAL_STORAGE”,

            “android.permission.ACCESS_NETWORK_STATE”,

        },

        usesFeatures =

        {

            { name=“android.hardware.camera”, required=true },

        },

    },

}

[/lua]

I don’t know how [[ ]] got there. But good news thanks to you Brent Sorrentino. I was able to get the capture button to save the photo in the gallery of my device by removing [[ ]].

Here is my new build.settings.

settings = {

        plugins =
    {
        [“CoronaProvider.ads.admob”] =
        {
            publisherId = “com.coronalabs”
        },
    },      

    
    orientation = {
        default = “landscapeRight”,
        supported = { “landscapeLeft”, “landscapeRight” },
    },
    
    
     --Android permissions

    android =
    {
        versionCode = “11”,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.WRITE_EXTERNAL_STORAGE”,
            “android.permission.ACCESS_NETWORK_STATE”,
        },
 
        usesFeatures =
        {
            { name=“android.hardware.camera”, required=true },
        },
 
    },
}