0

I have this live wallpaper where you can choose your own custom background and immediately at start the app checks if the filepath exists, if not it flags for drawing just a black screen. The thing is, every time I restart the phone the background does not get drawn, however it is drawn in Live Wallpaper preview.

I highly suspect Media Scanner or the fact that all directories are not mounted yet, but what should I do about it?

Aron
  • 144
  • 2
  • 11
  • Have you considered making a lower resolution copy of the file into your live wallpaper when an image is set, basically caching the image? This way the media scanner won't interfere, since the wallpaper contains its source image already. – gkiar Jun 29 '12 at 18:19
  • @iKiar hmm I dont quite understand, you mean I should cache the chosen image somehow? Because the point is that the user can choose an image from their on phone. – Aron Jun 29 '12 at 18:23
  • 1
    Sorry, I will try to be more clear. I am suggesting that once the user selects the image from their own local files, in the process of setting that as the background, you also create a cached file in a local resources for your application. That way, it is readily available upon startup. If the user requests to change their image, simply overwrite the cached file you had before with the new one. – gkiar Jun 29 '12 at 18:27

3 Answers3

0

Wallpaper engine create every time when you click on preview and when you set a wallpaper. so the problem is you must be holding a path of file in a variable which is in the engine. make this variable a class level. it will work

Ravi Bhojani
  • 1,032
  • 1
  • 13
  • 24
  • thanks, but thats not the problem. The image-background is working fine both in preview and at home-screen until restart. The path is by the way stored in a SharedPreferences database. – Aron Jul 01 '12 at 15:17
  • I have faced same issue. What i have done is onSharedPreferenceChanged() i am checking key. If key is null then i am taking all my data from preference. When you restart a phone your engine created and it will pass key as null. – Ravi Bhojani Jul 02 '12 at 19:58
0

I have faced same issue. What i have done is onSharedPreferenceChanged() i am checking key. If key is null then i am taking all my data from preference. When you restart a phone your engine created and it will pass key as null

Ravi Bhojani
  • 1,032
  • 1
  • 13
  • 24
0

Appearantly the solution is to register Intent.ACTION_MEDIA_MOUNTED with a broadcast receiver. This seems to work even without any real external media (appearantly the same thing as external storage media which isnt just physically external storage)

android intent for sdcard ready

Community
  • 1
  • 1
Aron
  • 144
  • 2
  • 11