我已经编写了自己的ImageViewer,现在我希望将Set设置为 Android原生ImageViewer中的功能.我现在有可能,因为Facebook有它.我附上了截图,让自己更加清晰.
PS我想更详细地解释出现了什么问题.在菜单中选择"联系人图标"后,将显示我的联系人列表.当我选择联系人时,申请人关闭.如果我选择"Home/Lock screen wallpaper",它会打开我手机的图库.这是我的代码片段:
Bitmap icon = mBitmap;
Intent setAs = new Intent(Intent.ACTION_ATTACH_DATA);
setAs.setType("image/jpg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "/my_tmp_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
setAs.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/my_tmp_file.jpg"));
startActivity(Intent.createChooser(setAs, "Set Image As"));
Run Code Online (Sandbox Code Playgroud)
我还为我的清单添加了后续权限,我可以将我的图像写入手机的SD卡.
