在我的应用程序中实现设置为图片按钮

时间:2015-06-26 21:14:56

标签: android profile

我使用json从webservice显示图像。现在如何提供用户将图像作为whatsapp或联系人照片等的个人资料图片,如何调用打开设置图片的意图为 - >设为 - >显示多个选项 - >联系照片壁纸,whatsapp个人资料照片等,?

 Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
 intent.setDataAndType(Uri.parse(filename.getAbsolutePath()), "image/*");
 intent.putExtra("jpg", "image/*");
 startActivity(Intent.createChooser(intent, ("set as")));

1 个答案:

答案 0 :(得分:1)

使用此代码。

File externalFile=new File("filePath")    
Uri sendUri = Uri.fromFile(externalFile)
        Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
                intent.setDataAndType(sendUri, "image/jpg");
                intent.putExtra("mimeType", "image/jpg");
                startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
相关问题