0

Is there a way to let my app know that Media (SDCard) was mounted/unmounted while my app was turned off? I mean that my app and its services were Destroyed, not only stopped. Probably, some ways to check MediaStore checksum are available?

Goal: decide if new music files were added or deleted in device memory to refresh general playlist.

Sergii
  • 1,521
  • 3
  • 24
  • 37

2 Answers2

1

Why not check if the SDCARD is mounted by using Environment.getExternalStorageState() upon restarting your app? The value you want it to be is Environment.MEDIA_MOUNTED. You could do it async and display a message somewhere stating that an update is in progress, however...

...if it's really the callback-ish thing you need, then you'll have to have a look at what John Willis wrote about registering a BroadcastReceiver.

Community
  • 1
  • 1
karllindmark
  • 6,031
  • 1
  • 26
  • 41
1

You have register a broadcast receiver to receive an intent android.intent.action.MEDIA_MOUNTED

Vishwanath.M
  • 6,235
  • 11
  • 42
  • 56
  • thanks, its right idea, but it's better to register Intent.ACTION_MEDIA_SCANNER_FINISHED - when MediaStore is already updated – Sergii Jul 11 '12 at 08:45
  • I think that answer by @ninetwozero is more informative, so I've accepted it. But I put "useful answer" for your advice. Thanks again! – Sergii Jul 11 '12 at 08:57