2012/8/14 Nathan <[email protected]> > > > On Monday, August 13, 2012 3:18:14 PM UTC-7, Kostya Vasilyev wrote: > >> >> The media scanner has a utility class in the framework: >> >> http://developer.android.com/**reference/android/media/** >> MediaScannerConnection.html<http://developer.android.com/reference/android/media/MediaScannerConnection.html> >> >> The easiest thing you can do is to call static MediaScannerConnection.** >> scanFile. >> > > Well, that requires API 8. >
But you only truly need it for MTP at API 14 and higher. Or for 2.* in some cases (like getting image files to show up in the gallery app). > > Could I call > > MediaScannerConnection conn = new MediaScannerConnection(this,null); > conn.scanfile(filepath,mimetype); > Not like that. > > That appears to work all the way back to API 1 - but is that too easy? > You need to call connect() first, and only when it's done connecting to the system service can you call scanFile. Don't forget to call disconnect when done. I pasted a bit of code here, hopefully it makes sense: https://gist.github.com/3344643 > > >> And does the .nomedia file matter? >> > > >> According to the docs, it makes the media scanner ignore the directory. >> Not sure if it has an effect on the scans you initiate yourself... >> > > So that is still a maybe. The documentation says that *media applications* > ignore the directory. It doesn't say if the media scanner, which now scans > all files, ignores it too. File explorer apps don't appear to ignore the > path. > A file manager type app most likely uses plain file system calls. -- K -- 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

