我可以在广播接收器中获取墙纸更改事件吗? 我需要检测用户是否更换了墙纸。 我该怎么办?墙纸更改事件
我在做什么: 我有一个可以自动更换壁纸的应用程序。 如果用户使用不同的应用程序手动更改它,我希望注意它并询问用户他/她是否要将该新壁纸添加到我的应用程序的列表中
我可以在广播接收器中获取墙纸更改事件吗? 我需要检测用户是否更换了墙纸。 我该怎么办?墙纸更改事件
我在做什么: 我有一个可以自动更换壁纸的应用程序。 如果用户使用不同的应用程序手动更改它,我希望注意它并询问用户他/她是否要将该新壁纸添加到我的应用程序的列表中
只有用于当壁纸图像变化的广播:http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED
做你想做什么,你需要不得不使用它来确定更多的逻辑,如果壁纸已经变为东西,除了图像: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.
*/
真实的故事。
我不相信任何东西会被广播。
WallpaperManager确实有一些getters会返回当前壁纸给你作为drawable。也许你可以将当前版本与存储的副本进行比较,以确定它是否已更改。但是,如果您使用此功能通过在已设置壁纸后更改壁纸来欺骗用户,请务必知道,我希望您在光着脚的黑暗中踏上乐高。
为什么你需要这样做?如果您提供有关您想要完成的内容的信息,它可以帮助人们回答问题。 – hackbod
好的。我正在做的是: 我有一个应用程序,每天自动更换壁纸。 如果用户使用不同的应用程序手动更改它,我希望注意它,并询问用户他/她是否要将该新壁纸添加到我的应用程序列表中 – Ton