Mount/Unmount SDcard, or Simulate it - Android

为君一笑 提交于 2019-12-13 06:42:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!