0

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.

Community
  • 1
  • 1
  • I haven't tried much, I've looked up many posts on similar but I really don't understand what they are saying. I know I need and that's about it. – CarsonBath0792 Jul 07 '12 at 19:34
  • This could be a good question, but you haven't provided any details, links, what you tried so far, what you mean by "simulate", etc. – Alex Lockwood Jul 07 '12 at 19:35
  • I don't think your app needs permission to mount/unmount filesystems to scan the media on your phone. In fact, I doubt the Music player app has the permission to unmount the sdcard either... – Alex Lockwood Jul 07 '12 at 19:37
  • I am not scanning for media, the built-in music player for Android phones 'scans' for media files. 'My' app puts more files onto the sdcard, I need to get the default music playing device to rescan the sdcard again. – CarsonBath0792 Jul 07 '12 at 19:39
  • OP: Voting to close, and downvoting, this kind of question is going to get burned, as you have stated in the comment '**I haven't tried much**' – t0mm13b Jul 07 '12 at 19:45
  • I don't know what to do... That's why I haven't tried much, let me rephrase my question. – CarsonBath0792 Jul 07 '12 at 19:46
  • I understand, my question was poor and I do not blame y'all, but I really don't have a direction here. – CarsonBath0792 Jul 07 '12 at 19:53
  • possible duplicate of [How to make the standard musik player find my files](http://stackoverflow.com/questions/6144402/how-to-make-the-standard-musik-player-find-my-files) – FoamyGuy Jul 07 '12 at 20:05
  • Definitely a relevant question, and answer. +1 – justinkoh Oct 09 '13 at 09:22

1 Answers1

4
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.

FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • This is literally exactly what I needed. Thank you for seeing my flamed question through, the 'sendBroadcast' method was unknown to me. – CarsonBath0792 Jul 07 '12 at 20:01