Android'设为墙纸'功能性 [英] Android 'set As Wallpaper' functionality

查看:133
本文介绍了Android'设为墙纸'功能性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有图库的应用程序,当我单击任何图像时,它将以完整模式打开.但是我想要设置为墙纸功能,例如android默认库:

I am developing an application in which I have an image gallery and when I click on any image, it opens in full mode. But I want the set As Wallpaper functionality like android default gallery:

我知道可以通过自定义代码(设置墙纸和裁剪图像)来完成.但我想将该图像传递给android默认壁纸设置器,以便android将管理裁剪和设置壁纸任务.我怎样才能做到这一点?如何将该图像传递给android默认的walpaper设置器?

I know it can be done by custom code (setting wallpaper and cropping image). But I want to pass that image to android default wallpaper setter so that android will manage the cropping and setting wallpaper task. How can I do that? How can I pass that image to android default walpaper setter?

推荐答案

您可以通过启动活动启动裁剪意图"以获取结果并在结果中检索它,然后使用墙纸管理器类.像这样

You can launch Crop intent by start activity for result and retrieve it in result and then use wallpaper manager class. like this

Uri imgUri=Uri.parse("android.resource://your.package.name/"+R.drawable.image); 
Intent intent = new Intent("com.android.camera.action.CROP");  
intent.setDataAndType(imgUri, "image/*");  
intent.putExtra("crop", "true");  
intent.putExtra("aspectX", 1);  
intent.putExtra("aspectY", 1);  
intent.putExtra("outputX", 80);  
intent.putExtra("outputY", 80);  
intent.putExtra("return-data", true);
startActivityForResult(intent, REQUEST_CODE_CROP_PHOTO);

并在onResult函数中使用墙纸管理器

and use Wallpaper manager in your onResult function

还请记住,是否支持该设备取决于设备.此Intent操作不是内部API的一部分.一些制造商提供了自己的Gallery应用程序,因此无法知道用户的设备是否会识别该意图.

Also keep in mind that It depends on the device whether that device is support it or not. This Intent action is not part of the internal API. Some manufacturers provide their own Gallery apps and so there is no way of knowing whether or not the user's device will recognize the Intent.

这篇关于Android'设为墙纸'功能性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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