以编程方式设置动态壁纸
是否可以使用几行代码设置动态壁纸。例如,我想告诉我的用户可以使用动态壁纸“单击此处进行设置”。
Is it possible to set a live wallpaper using some lines of code. For example, i want to tell my users that a live wallpaper is available "click here to set it".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
现在有两种方法可以实现这一点,因为 Jelly Bean 提供了直接设置动态壁纸的方法。此样板代码将选择可用的最佳方法。
There are now two ways to accomplish this as Jelly Bean provides a way to directly set the live wallpaper. This boilerplate code will choose the best method available.
好吧,这样我就不会因为过时的答案而遭到反对。请参阅下面的错误 454 的答案,以获得更强大的解决方案,该解决方案会将用户直接发送到 Jelly Bean 及更高版本设备上的壁纸预览屏幕。
==========================================
下面介绍如何启动壁纸选择器,从中用户可以选择您的壁纸。 Toast 只是向用户解释发生了什么的一种方式。
Alright, just so I stop getting downvotes for an outdated answer. Please see Error 454's answer below for a more robust solution which will send the user directly to the wallpaper preview screen on Jelly Bean and up devices.
========================================
Here's how to start the wallpaper chooser, from which the user can select your wallpaper. The toast is just a way to explain to the user what's going on.
您应该使用 async_wallpaper 包来执行此操作。您可以通过 URL 轻松访问 mp4 文件并在您的应用程序中显示它们,也可以将它们应用到主屏幕上
You should use the async_wallpaper package to perform this operation. You can easily access the mp4 files through URLs and show them in your app and also apply them on the home screen
您必须让壁纸管理器来设置壁纸。这是我的一个应用程序中使用的代码,它使用 AsyncTask(已弃用),但您也可以使用 Kotlin 协程来实现。
You have to get wallpaper manager to set wallpaper. Here is the code that is used in one of my apps, It uses AsyncTask (which is deprecated) but you can implement with Kotlin coroutines as well.