Adding pictures to the Gallery - Android

三世轮回 提交于 2019-12-24 03:51:46

问题


I have an activity that takes a photo with the camera, and then 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!


回答1:


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




回答2:


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 :)



来源:https://stackoverflow.com/questions/2870906/adding-pictures-to-the-gallery-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!