Can I get a wallpaper changed event in a broadcast receiver?
I need to detect if the user changed the wall paper.
How could I do it?
What I am doing is this:
I have an app that changes wallpaper automaticly.
If the user changes it manually using a different aplication I would like to notice it and ask the users if he/she wants to add that new wallpaper to the list in my application
There is only a broadcast for when a wallpaper image changes: http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED
To do what you want, you will need to have more logic to use this to determine if the wallpaper has been changed to something besides an image: http://developer.android.com/reference/android/app/WallpaperManager.html#getWallpaperInfo()
To be honest, if you are making a wallpaper that is going to change, you really should consider just writing a live wallpaper. This will fit much more comfortably into the system: you can change what you are showing whenever you want, and it is clear when the user has selected a different wallpaper because your live wallpaper will be stopped.
Also you need to be extremely careful about the use of ACTION_WALLPAPER_CHANGED, because it can get you into bad interactions with other applications. Here is the documentation for it that will appear in the next API:
/**
* Broadcast Action: The current system wallpaper has changed. See
* {@link android.app.WallpaperManager} for retrieving the new wallpaper.
* This should <em>only</em> be used to determine when the wallpaper
* has changed to show the new wallpaper to the user. You should certainly
* never, in response to this, change the wallpaper or other attributes of
* it such as the suggested size. That would be crazy, right? You'd cause
* all kinds of loops, especially if other apps are doing similar things,
* right? Of course. So please don't do this.
*
* @deprecated Modern applications should use
* {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
* WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
* shown behind their UI, rather than watching for this broadcast and
* rendering the wallpaper on their own.
*/
True story.
I don't believe that anything gets broadcast.
WallpaperManager does have some getters that will return the current wallpaper to you as a drawable. Perhaps you could compare the current one to a stored copy to determine if it has been changed. However if you are using this functionality to trick users by changing the wallpaper after they already set it, do know, I hope you step on a lego in the dark with your bare foot.