Android - 如何设置壁纸图像?
可能的重复:
Android - 如何设置壁纸图像
我正在尝试什么要做的是,使用图像 URI 设置壁纸(不裁剪)
我是 Android 开发人员和一般开发人员。 互联网让我失望...无法提供设置壁纸的代码。
是开发资源网站说
public void setStream (InputStream data)
但我不明白,一些示例代码会对我有很大帮助。
Possible Duplicate:
Android - how to set the wallpaper image
What i'm trying to do is, set the wallpaper using an image URI (no cropping)
I'm a noob at dev on Android and dev in general.
The internet has failed me... on providing code to set the wallpaper.
yes the dev resource site says
public void setStream (InputStream data)
but i don't understand it, some sample code would greatly help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您好,如果您有图像路径,您可以使用此代码。
如果您有图像 URI,请使用此
如果有任何问题请告诉我。
Hi you can use this code if You have Image path.
if you have image URI then use this
Let me know if there is any issue .
如果您有图像 URL,则可以使用流(抽象)打开它代表的资源:
新 URL("your.image.url.com").openStream()
。此方法调用将返回一个InputStream
类型的对象,您可以将其作为参数传递给setStream()
方法。如果您不想直接指定流,则可以打开远程流,创建位图,然后使用 WallpaperManager 实例或执行
context.setWallpaper(bitmap)
(已弃用)将位图设置为壁纸。作为参考,请查看 这个线程。
If you have the image URL you can open the resource it represent using the stream(abstraction):
new URL("your.image.url.com").openStream()
. This method call will return an object of typeInputStream
which you can pass as an argument tosetStream()
method.If you dont want to specify a stream directly, you can open the remote stream, create a Bitmap and then either use a WallpaperManager instance or do a
context.setWallpaper(bitmap)
(this is deprecated) to set your bitmap as the wallpaper.For reference take a look at this thread.