首页 文章

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

提问于
浏览
2

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

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 回答

  • 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);
    

相关问题