I posted this over on StackOverflow weeks ago, but not even a nibble - hoping someone here has seen this or has any suggestions.
http://stackoverflow.com/questions/5207221/android-problem-with-media-scanner-not-running I have an app that user's can draw with, and then 'export' that drawing as a .png file to external storage, if present. Generating the PNG, copying the file to external all work like a charm, but a rather unique problem happens; after the export, if the user navigates to the image via My files (Samsung Tab running 2.2 in this case), they can see the .png file, but when they open it, the screen is black for about 10 seconds... then they see the image, Additionally, the images don't show up in the user's 'Gallery' app either. Now, if the user connects the device to the computer via USB, or reboots the device, they can access the images no problem from My files, and they appear in 'Gallery' from that point forward, but again, any newly esported files experience the same problems until they cycle/connect the device again. My thinking was that this had to be related to the Media Scanner (at least in the case of the 'Gallery' problem, it most certainly is). So, as I am targetting Api 8+, I am trying to use the static MediaScannerConnection.scanFile() method to have the OS re-scan and add my images into the Gallery, etc. Also hoping this solves the issue of the strange delay in opening the images. Looking at LogCat, I have this related to the MediaScanner: DEBUG/MediaScannerService(2567): IMediaScannerService.scanFile: /mnt/ sdcard/MyApp mimeType: null DEBUG/MediaScannerService(2567): onStartCommand : intent - Intent { cmp=com.android.providers.media/.MediaScannerService (has extras) } DEBUG/MediaScannerService(2567): onStartCommand : flags [0], startId [1] DEBUG/MediaScannerService(2567): ServiceHandler:handleMessage volume[null], filePath[/mnt/sdcard/MyApp] DEBUG/MediaProvider(2567): getSdSerial() sd state = removed INFO/Database(2567): sqlite returned: error code = 17, msg = prepared statement aborts at 43: [SELECT DISTINCT sd_serial FROM images WHERE sd_serial LIKE 'external_0x%'] ERROR/MediaProvider(2567): removeMediaDBData called DEBUG/MediaScanner(2567): prescan enter: path - /mnt/sdcard/MyApp DEBUG/MediaScanner(2567): prescan return So, it looks like the MediaScanner is getting the correct location, but is failing to find the SD card, which is correct, and failing. The Samsung Tab has built-in non-SD external storage, which Android gives access to via Environment.getExternalStorageDirectory(). How do I tell it to scan the non-SD storage? Note that I also get this exact error on the emulator, and manually invoking the media scanner from the Dev Tools solves the issues of the exported images being properly recognized. Any ideas how to proceed? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

