通过GALLARY应用程序设置壁纸 [英] Set wallpaper via Gallary app

查看:238
本文介绍了通过GALLARY应用程序设置壁纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找周围是否有可能直接从Android SDK中设置壁纸为锁屏但不幸的是它尚未公布,但怎么过我已经看到了一些能够做的应用程序,通过股票GALLARY应用如图片
是有一定目的的GALLARY应用设置一定的形象作为墙纸?
谢谢

i was looking around if it's possible to set Wallpaper for Lockscreen directly from android Sdk but unfortunately it's not available yet but how ever i have seen some apps able to do that via Stock gallary app as in the picture is there a certain intent for gallary app to set A certain image as wallpaper ? Thanks

推荐答案

您可以设置位图作为使用的 WallpaperManager 。它定义了方法<一href=\"http://developer.android.com/reference/android/app/WallpaperManager.html#setBitmap%28android.graphics.Bitmap%29\"相对=nofollow> setBitmap()它允许你设置位图作为墙纸。

You can set a Bitmap as a wallpaper using the WallpaperManager. It defines a method setBitmap() which allows you to set the bitmap as wallpaper.

然而,要做到这一点,你需要设置在清单中定义墙纸的权限。

However, to do that, you need the permission to set the wallpaper to be defined in the manifest.

如何将我的位图发送到GALLARY 结果
您需要创建相应的扩展名的文件,然后使用 COM $ p $(PSS)方法将其写入该文件。结果
这里是一个快速code,我从另外一个答案承担了这样:

how can i send my bitmap to gallary
You need to create a file with appropriate extension and then use the compress() method to write it to that file.
Here is a quick code that I took from another answer on SO:

try {
       FileOutputStream out = new FileOutputStream(filename);
       bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
       e.printStackTrace();
}

这篇关于通过GALLARY应用程序设置壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆