On Tue, Aug 14, 2012 at 4:47 PM, Kostya Vasilyev <[email protected]> wrote: > > 2012/8/14 Nikolay Elenkov <[email protected]> >> >> On Tue, Aug 14, 2012 at 7:18 AM, Kostya Vasilyev <[email protected]> >> wrote: >> >> > >> > >> > The media scanner has a utility class in the framework: >> > >> > >> > http://developer.android.com/reference/android/media/MediaScannerConnection.html >> > >> > The easiest thing you can do is to call static >> > MediaScannerConnection.scanFile. >> > >> >> BTW, this method never closes the connection it opens, so you will get >> 'leaked service connection' (or some such) warnings in logcat if yo use >> it. > > > Hmm, there is a call to mConnection.disconnect in ClientProxy, line 204: > > https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/MediaScannerConnection.java > > Perhaps it was added recently?
It's been there at least since GB. Looks like it should get closed, so it looks like my assumption is (mostly?) wrong. > > It won't trigger if scanning a particular path element doesn't result in > onScanCompleted(), though -- wonder if it can? > Not sure, but here's one warning I got recently, and I've had reports of this before. This is for scanning a single file. Service com.github.andlyticsproject.io.ExportService has leaked ServiceConnection android.media.MediaScannerConnection@4149279 that was originally bound here android.app.ServiceConnectionLeaked: Service com.github.andlyticsproject.io.ExportService has leaked ServiceConnection android.media.MediaScannerConnection@4149279 that was originally bound here at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:965) at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:859) at android.app.ContextImpl.bindService(ContextImpl.java:1216) at android.app.ContextImpl.bindService(ContextImpl.java:1208) at android.content.ContextWrapper.bindService(ContextWrapper.java:394) at android.media.MediaScannerConnection.connect(MediaScannerConnection.java:116) at android.media.MediaScannerConnection.scanFile(MediaScannerConnection.java:235) at com.github.andlyticsproject.io.MediaScannerWrapper.scanFile(MediaScannerWrapper.java:15) at com.github.andlyticsproject.util.Utils.scanFile(Utils.java:81) at com.github.andlyticsproject.io.ExportService.exportStats(ExportService.java:102) at com.github.andlyticsproject.io.ExportService.onHandleIntent(ExportService.java:71) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.os.HandlerThread.run(HandlerThread.java:60) -- 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

