eezszi avatar image
eezszi asked

Saved image not showing up in gallery

We are saving an image to our app's directory and scanning the file with the MediaScanner, yet the image does not show up in the gallery until you browse to the location with a File Explorer app. We are using Unity and Prime31 and have the logs below for the file successfully saved and scanned. This is happening on a Generation 1 Kindle Fire. Once we browse to that folder, future screenshots show up in the gallery automatically, but a user is not going to do that. 10-31 11:04:52.421: I/Unity(5799): [LOG] Took screenshot to: /mnt/sdcard/Android/data/com.schoolzone.a9975/files/I Like to Paint/screen_600x1004_2013-10-31_11-04-52.png 10-31 11:04:52.531: I/Prime31(5799): scanner set 10-31 11:04:52.531: I/Prime31(5799): saved to gallery with uri: content://media/external/images/media/23 10-31 11:04:52.539: I/Prime31(5799): scanner connected 10-31 11:04:52.539: D/MediaScannerService(5108): IMediaScannerService.scanFile: /mnt/sdcard/Android/data/com.schoolzone.a9975/files/I Like to Paint/screen_600x1004_2013-10-31_11-04-52.png mimeType: image/png 10-31 11:04:52.734: I/Prime31(5799): scanner finished for file: /mnt/sdcard/Android/data/com.schoolzone.a9975/files/I Like to Paint/screen_600x1004_2013-10-31_11-04-52.png commented 15 minutes ago by HailfireGames From Prime31: There are no errors in that log. The scanner completed for the file. If it still isn't appearing in the gallery you will need to open a bug report with the Amazon crew. The only API exposed is the scanner and if it succeeds then that is all the information that we can provide. commented 4 minutes ago by prime31
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

DougM@Amazon avatar image
DougM@Amazon answered
Hello eezszi, We have seen this happen on other android tablets as well. Using the following code below will allow you to force a scan of your external storage directory, and as a result, it should populate the gallery application with any photos that were taken recently. AndroidJavaClass classPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer”); AndroidJavaObject objActivity = classPlayer.GetStatic ("currentActivity”); AndroidJavaClass classUri = new AndroidJavaClass("”); AndroidJavaClass environment = new AndroidJavaClass("android.os.Environment”); AndroidJavaObject objFile = environment.CallStatic ("getExternalStorageDirectory”); string path = objFile.Call ("getAbsolutePath”); AndroidJavaObject objIntent = new AndroidJavaObject("android.content.Intent", new object[2]{"android.intent.action.MEDIA_MOUNTED", classUri.CallStatic ("parse", "file://"+path)}); objActivity.Call ("sendBroadcast", objIntent);
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.