I've been trying to create a simple MP3 downloader for Android. All it does is connect to the URL, downloads the track and guesses the ID3 information based on the name. The problem with my application is that once a song is downloaded, it does not instantly show up in the Google Music app, nor in the default music player application. I even tried some other ones without luck, they all do not reindex it.
The only thing I noticed was that when I copied/moved the song from the Music folder on my SD card to the root of the SD card, it reindexed the entire library properly. This gave me the idea that it might not be alerting any file listeners.
My question is: how would I be able to save a song to the Music folder, and having the music players update their indices? Thank you in advance.
Another reason for songs not showing in Play Music might be due to a corrupted memory card. Remove the card and then insert it again. Check if the songs are visible. In case the songs are stored on the internal memory, remove the card and check without it.
Go to Settings > Apps > Media Storage > Clear data. Hope it works. It worked in my case.
To refresh the list of your music you do following: Go into settings->manage apps->ALL services. Scroll down and select "Media Storage." Then hit the "Clear Data" icon. Good to know from the same source: You must then reboot your phone, and at boot the phone runs the media update service in the background.
You need to notify the MediaScanner
that a new file has been added and should be indexed so it shows up in the MediaStore
.
The simplest way is to send a broadcast once the file has been downloaded:
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(file));
sendBroadcast(intent);
http://developer.android.com/reference/android/content/Intent.html#ACTION_MEDIA_SCANNER_SCAN_FILE
The assumes the "other music players" use the MediaStore, but it's a good bet that they do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With