Android的“设置为墙纸”功能 [英] Android 'set As Wallpaper' functionality

查看:223
本文介绍了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:

我知道它可以通过自定义的code来完成(设置墙纸和裁剪图像)。但我想这种形象传递给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

另外请记住,这取决于设备该设备是否支持与否。这种意图的行动是不是内部API的一部分。一些制造商提供自己的照片应用程序,因此没有办法知道用户的设备是否会承认的意向。

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天全站免登陆