I run a service when the device boots and that service just loads an image from sd card and makes it wallpaper. When the device starts i get an error. But after the sd card finishes the loading the service sets the image as wallpaper fine.
<action android:name="android.intent.action.BOOT_COMPLETED" />
I start the service like this ^ and i want to ask if there is a way to start the service after sd card finishes loading.
The MEDIA_MOUNTED action will work here, but you must include an intent filter for it in the manifest file, and you must also change the data scheme for the receiver's intent filter to "file" as well.
You can wait for the SD card to load. One way is to use the
android.intent.action.MEDIA_MOUNTED
action.Another way is to poll up to some maximum and give up if not mounted:
Hope this helps.
Edit: I didn't know there was a intent for MEDIA_MOUNTED, I would use the answer posted below instead.
What I would do is launch the service how you have it and inside of the service keep checking to see when the sdcard is mounted, maybe every 300ms or something. This question shows how to detect if the sdcard has been mounted or not.
There's an intent broadcast for after media (SD card) is mounted with the action set to MEDIA_MOUNTED.