I got little problem. I’m refreshing my sdcard using:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
and I have created ProgressDialog with a spinner which pops out at the start (“at the start” – I mean after sendBroadcast method), and after successful refresh I would like to dismiss it, but I got no idea how to check that MediaScanner finished his job. I tried using BroadcastReciver and sendStickyOrderedBroadcast(...), but its seems it was wrong idea…
I can’t use MediaScannerConnection and OnScanCompletedListener() because I don’t have direct paths to the files (in some situations, it doesn’t exist).
Does anyone have any idea how to solve my problem? I have run out of ideas
When you send a broadcast you can’t expect a result.
The only way you will ever get one is if the receiver (in this case the MediaScannerService which catches the ACTION_MEDIA_MOUNTED broadcast) sends its own broadcast with an update on the “job”.
You should be able to catch ACTION_MEDIA_SCANNER_FINISHED for your current circumstance, however if you want more control (i.e. to scan specific files or a scan progress) you could implement MediaScannerConnectionClient.