我有一个活动,用相机拍照,然后将其添加到正确的文件夹(在本例中为 /DCIM/Camera)。但是当你退出应用程序并加载 Android 图库时......它不在那里。我正在玩一些游戏,发现它只在重新启动手机后才出现。我不确定这背后的原因(也许它必须创建缩略图?)...有什么办法解决这个问题吗?我希望它立即显示出来。
谢谢!
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!
发布评论
评论(2)
您需要使用新添加照片的路径运行 MediaScanner。届时将出现在图书馆。 API Level 8 为此提供了一个方便的函数,称为 scanFile。
详细信息请参见 http://developer.android.com/reference/android/media/MediaScannerConnection .html
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
从应用程序屏幕中选择“开发工具”,然后选择“媒体扫描仪”(或较新版本的 Android 中的“媒体提供程序”)以使模拟器识别文件,以便将它们显示在媒体库中。
如果您认为它解决了您的问题,请将答案标记为正确。真好:)
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 :)