我想将存储在资源文件夹中的图像复制到剪贴板管理器,以便稍后粘贴到另一个应用程序上,如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)