小编Val*_*kon的帖子

如何在Android上将图像复制到clipboardManager,例如?

我想将存储在资源文件夹中的图像复制到剪贴板管理器,以便稍后粘贴到另一个应用程序上,如mail,whatapp或chat.我有研究员几个链接一些提到这可以做到一个文件的uri.

这是我得到的最好的,可以帮我指出一个有效的例子.

File imageFile = new File("file:///android_asset/coco_001.png");
ContentValues values = new ContentValues(2);

values.put(MediaStore.Images.Media.MIME_TYPE, "image/png");
values.put(MediaStore.Images.Media.DATA, imageFile.getAbsolutePath());
ContentResolver theContent = getContentResolver();
Uri  imageUri = theContent.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);  
ClipData theClip = ClipData.newUri(getContentResolver(),"Image", imageUri);
Run Code Online (Sandbox Code Playgroud)

android image copy-paste clipboardmanager

5
推荐指数
1
解决办法
2189
查看次数

标签 统计

android ×1

clipboardmanager ×1

copy-paste ×1

image ×1