How To Make The Standard Music Player Find My Files
My App downloads some mp3 files to sdcard. I want to play them with other music players installed on the device. But the other music players don't automatically find my downloaded
Solution 1:
You can force the scan of media file with a broadcast:
sendBroadcast(newIntent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Solution 2:
Make sure the folder that your files are in do not have a file called ".nomedia" in them. That file tells the MediaScanner not to check there.
(note: there is a "." in front of nomedia, which means it may be hidden)
Solution 3:
Here is an easy 'single file based solution':
Whenever you add or remove a file, let MediaStore Content Provider knows about it using
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(imageAddedOrDeleted)));
Main advantage: work with any mime type supported by MediaStore
Note:
sendBroadcast(newIntent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
is too expensive and scan everything. My advice: if you can, use the 'per file' approach.
Post a Comment for "How To Make The Standard Music Player Find My Files"