我可以在广播接收器中获取壁纸更改事件吗?
我需要检测用户是否更改了壁纸。
我怎样才能做到呢?
我正在做的是这样的:
我有一个可以自动更改壁纸的应用程序。
如果用户使用不同的应用程序手动更改它,我想注意到它并询问用户是否要将新壁纸添加到我的应用程序的列表中
仅当壁纸图像发生变化时才会进行广播:http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED
为了做你想做的事,你需要有更多的逻辑来使用它来确定壁纸是否已更改为除图像之外的其他内容:http://developer.android.com/reference/android/app/WallpaperManager.html#getWallpaperInfo http://developer.android.com/reference/android/app/WallpaperManager.html#getWallpaperInfo()
老实说,如果你正在制作一个会改变的壁纸,你真的应该考虑只写一个动态壁纸。这将更适合系统:您可以随时更改显示的内容,并且当用户选择不同的壁纸时会很清楚,因为您的动态壁纸将被停止。
此外,您需要非常小心 ACTION_WALLPAPER_CHANGED 的使用,因为它可能会让您与其他应用程序发生不良交互。以下是将出现在下一个 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.
*/
真实的故事。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)