开发者

Adding pictures to the Gallery - Android

开发者 https://www.devze.com 2022-12-31 21:54 出处:网络
I have an activity that takes a photo with the camera, and then开发者_Python百科 adds it to its proper folder (in this case /DCIM/Camera). But then when you exit the app and load up the Android galler

I have an activity that takes a photo with the camera, and then开发者_Python百科 adds it to its proper folder (in this case /DCIM/Camera). But then when you exit the app and load up the Android gallery...it's not there. I was doing some playing around and noticed it only appears there when after restarting the phone. I'm not sure the reason behind this (maybe it has to create the thumbnail?)...is there any way around this? I want it to show up right away.

Thanks!


You need to run the MediaScanner with the path of the newly added photo. Will show up in the library then. API Level 8 has a convenient function for this called scanFile.

Details at http://developer.android.com/reference/android/media/MediaScannerConnection.html


Select "Dev Tools" from the Apps screen, the select "Media Scanner" (or "Media Provider" in newer versions of Android) to get the emulator to recognize the files so they would be displayed in the Media Gallery. Pls mark the ans as correct if you think it resolved your issue. tnks :)

0

精彩评论

暂无评论...
验证码 换一张
取 消