|
I want to make a screenshot of the Android screen while playing the game by pressing a GUI button and save it to the android's Gallery. I found a tutorial that details how to save images to the android's gallery using the SDK and java. Here's the link http://developer.android.com/training/camera/photobasics.html My problem is that I don't understand how to use java with unity. My basic understanding is that I need to either make a library or a plugin. Is that correct? Can you point me to a tutorial that walks me through the process? Or suggest another approach? Thanks!
(comments are locked)
|
|
After lots of digging, I've found a solution, but it's made me realize that this post probably should have been three separate questions. RE: How to use Java Plugins in Unity
RE: How to make and save an Android Screenshot
Second, to view the screenshot from the android file manager, the file path needs to be set using RE: Android Gallery
I don't think it's so complicated that you will have to write a Plugin... You just need to have the user specify where their Android Gallery path is (if it's different than the default) ... then use the method to capture the screen @ http://answers.unity3d.com/questions/59944/accessing-the-iphone-or-android-camera-for-screens.html
Jan 21 '12 at 04:52 PM
ina
/sdcard/DCIM/camera/ or /sdcard/media/images/
Jan 21 '12 at 04:54 PM
ina
I came to the conclusion that no plugins were necessary too, but since it was part of my original question, I thought I should answer that part too. I used your post as a starting point actually about two weeks ago, but at the time I didn't have commenting or upvoting privileges. :) Thanks for the help.
Jan 21 '12 at 04:59 PM
cmauceri
I think instead of messing with plugins, I'm going to allow the automatic media scan to take care of updating the gallery, and simply inform the user that the image will be available there on reboot.
Jan 21 '12 at 07:09 PM
cmauceri
You have to send an update to the media content provider for the image to show up right after you saved it. I have to dig for the code in one of our projects, do you still need it?
Aug 15 '12 at 08:59 PM
marsbear
(comments are locked)
|
|
I got a partial answer for the 'saving an image in the users gallery on Android' part of the question. That's how we do it in native Android. I will look for a solution from Unity. This is pretty much copy and paste from one of our previous projects. I removed some of the error handling (you have to check for the existence of the folder etc). INSERTSOMEVIEWHERE is some view in Android. This code is basically meant to take a screenshot from a particular view ans save it in the gallery. You can take the root view if you want to take a screenshot of the whole app. There is that external helper function directoryAndStorage.getOrCreatePictureDirectory I use to create a folder in the users gallery depending on which device we are running on (Some devices don't have an external storage and the Nook does not have the function getExternalStoragePublicDirectory). The helper function is far from complete, you could add support for different Android versions aswell: That's it so far. If you have questions, shoot. I'm going to post updates soon. Thanks for the code, but I'm capturing a snap from Unity, so I can't use that code to update the sdcard. I'm actually using [code] sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); [/code] which doesn't give me any errors. I just downloaded eclipse with the Android plugin, to compile it to a .jar and to use it as JNI... but yet, I have no idea on what I'm doing, so I haven't achieved anything yet.
Aug 20 '12 at 11:19 AM
Miyavi
My code would only be half the solution. You 'just' have to get your image into a Java plugin within your project. I can test how to do that but not before monday or tuesday.
Apr 05 at 03:10 PM
marsbear
(comments are locked)
|
|
Hey, any update here? I'm hitting on the same wall, so some pointers would be great.
(comments are locked)
|

related: http://answers.unity3d.com/questions/22954/how-to-save-a-picture-take-screenshot-from-a-camer.html - btw did you ever got to a good solution for this? it's quite annoying we can't simply replicate the native android's (or iPhone) native screenshot button behavior.