Android 使用 URI 设置壁纸
我有一个来自媒体存储的 URI 指向图像。我想用这个 URI 设置壁纸。我尝试使用 BitmapFactory.decodeFile 但问题是如果它很大,则会耗尽内存。
我还有其他方法可以做到这一点吗?
谢谢
I have a URI from the mediastore pointing to a image. I would like to set the wallpaper with this URI. I tryed using BitmapFactory.decodeFile but the problem is if its big it runs out of memory.
Is there another way i can do this.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题有点老了,但是,嘿……
你可以用下面的代码来解决这个问题。但是,如果您将图像做得非常小,然后将其拉伸以适合非常大的图像,则会降低质量。话虽这么说,如果图像太大,您甚至无法加载它,而您只想将其用作壁纸,我认为您可以接受以下内容。
This question is a bit old, but what the hey...
You can get around this problem with the following code. However, if you make the image very small, and then stretch it to fit something very big, you will loose quality. That being said, if the image is so huge you can't even load it, and you just want it to act as your wallpaper, I think you will be fine with the following.