Android-如何设置壁纸图片
是否可以通过编程方式设置 Android 壁纸图像?我想创建一项从网络下载图像并定期更新主屏幕壁纸的服务。
Is it possible to set the android wallpaper image programatically? I'd like to create a service that downloads an image from the web and updates the home screen wallpaper periodically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您有图像 URL,则使用
如果您有图像 URI,则使用
在清单文件中:
If you have image URL then use
If you have image URI then use
In your manifest file:
来自开发者的此页面地点:
From this page on the developer site:
如果您有图像位图,那么您将添加此功能以设置为壁纸:
您应该为此添加权限,
希望它能起作用
If you have bitmap of image than you will add this function to set as wallpaper:
you should add permission for this
hope it will work
好的,以下是 api 2.0 之前的操作方法:
您需要调用 getApplicationContext.setWallpaper() 并向其传递位图。
此方法现已弃用。有关新方法的详细信息,请参阅 ChrisF 的回答。
OK Here's how to do it before api 2.0:
You need to call getApplicationContext.setWallpaper() and pass it the bitmap.
This method is now deprecated. See ChrisF's answer for details on the new method.