问题
Edit: The default media player for Android phones scans the sdcard for song files and then allows the user to play these songs based on what it has scanned.
My app that I have made writes additional song files to the sdcard, but the default media player does not see these songs because it only scans for song files when it is either A: Rebooted (phone turns on). or B: when the phone's sdcard is mounted.
My problem is that I need to either programatically unmount/mount the sdcard, or simulate something that tricks the music player into thinking this has happened.
Mount sdcard programmitically in android states that I need to use a Settings app?
I do not wish to use another application. All other articles I have found revolve around the Emulator.
回答1:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Note that some manufacturers custom OS builds do not scan properly when this intent is broadcast. I had a motoblur device that I had to use something else in order to get working. Don't recall exactly what it was though.
来源:https://stackoverflow.com/questions/11378012/mount-unmount-sdcard-or-simulate-it-android