墙纸更改事件 [英] Wallpaper change event
问题描述
我可以得到一个广播接收机墙纸更改事件?
我需要的,如果用户更改墙纸检测。
我怎么能这样做呢?
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?
我在做什么是这样的:
我有全自动改变墙纸的应用程序。
如果用户手动将其使用不同的aplication改变,我想注意到它,并询问用户,如果他/她要添加新的墙纸到列表在我的应用
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
推荐答案
有只适用于当墙纸图像变化的广播:<一href=\"http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED\">http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED
There is only a broadcast for when a wallpaper image changes: http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED
要做到你想要什么,你将需要以此来确定更多的逻辑,如果墙纸已更改为东西,除了图像:<一href=\"http://developer.android.com/reference/android/app/WallpaperManager.html#getWallpaperInfo\">http://developer.android.com/reference/android/app/WallpaperManager.html#getWallpaperInfo()
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.
另外你必须非常小心使用ACTION_WALLPAPER_CHANGED的,因为它可以让你与其他应用程序交互不好。下面是这将出现下一个API的文档:
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.
*/
真实的故事。
这篇关于墙纸更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!