Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  3. Unity 2017.2 is now released.
    Dismiss Notice
  4. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Capturing screenshots to sdcard?

Discussion in 'Android' started by paulbrighton, May 1, 2012.

  1. paulbrighton

    paulbrighton

    Joined:
    Apr 28, 2012
    Posts:
    6
    I have an Samsung Galaxy Y (Android) and I'm using:

    Code (csharp):
    1. Application.CaptureScreenshot("/mnt/sdcard/DCIM/Camera/screenshot.jpg");
    I have the write access drop box set to external but nothing is showing up in this folder. :(

    This folder exists so I don't know why it isn't working?

    I also tried:

    Code (csharp):
    1. Application.CaptureScreenshot("/sdcard/DCIM/Camera/screenshot.jpg");
    If I try: Application.CaptureScreenshot("screenshot.jpg"); and run it in the editor it captures a screenshot just fine. Any ideas?
     
  2. paulbrighton

    paulbrighton

    Joined:
    Apr 28, 2012
    Posts:
    6
    I used the DDMS tool from the SDK and it gave me the error:

    Code (csharp):
    1. failed to open file at path: /mnt/sdcard/data/com.mycompany.myprogram/files/mnt/sdcard/DCIM/Camera/screenshot.png
    2.  
    So it seems like Application.captureScreenshot always tries to write to the folder /mnt/sdcard/data/com.mycompany.myprogram/files when either because it is installed on the sd card or because write access is set to external (not sure which yet). But I want to save it to /mnt/sdcard/DCIM/Camera/ so it will show up in the gallery is there a way to do this?

    I tried

    Code (csharp):
    1. Application.captureScreenshot( "../../../../DCIM/Camera/screenshot.png")
    which works but this can't be the best solution. Really I would like a way to write an absolute path to the sdcard and the DCIM folder.

    Is captureScreenshot supposed to behave like this or does this count as a bug?
     
    Last edited: May 2, 2012
  3. jemonsuarez

    jemonsuarez

    Joined:
    Sep 24, 2012
    Posts:
    59
    I'm trying the same, and seems that the "/mnt/sdcard/data/com.mycompany.myprogram/files" path is attached to the string automatically, but didn't find a way to set a different one. I'm not familiar with Linux, and wasn't able to find a "go root" command other than the "go parent folder (../)" command (I think '//' should work, but didn't tryed yet). This path is usefull to save inernal application data, but you can't retrieve this data from file system.
    I have tryed on Samsung Ace and it works, will update with other devices and maybe it is the best way to access the sdcard.
     
    Last edited: Oct 8, 2012
  4. kookyoo

    kookyoo

    Joined:
    Apr 19, 2010
    Posts:
    38
    Hi, I'm facing the same issue. Did anyone succeed in saving data to DCIM folfer ? For now on my Nexus4 I can only access to an emulated external sdcard (because the device doesn't have one and don't seem to want me to write on internal one) and I'm not able to read those data from a computer even if they really are present.
     
  5. jvil

    jvil

    Joined:
    Jul 13, 2012
    Posts:
    263
  6. maximus9600

    maximus9600

    Joined:
    Jun 9, 2014
    Posts:
    12
    Please note that Application.CaptureScreenShot is an asynchronous process. So it will take time for the image to appear. And if you want to open the image as soon as it is captured you can use the Application.persistentDatapath and copy its contents to the DCIM/Camera folder. Moving can take some time but i feel copy is a lot better