我想将存储在资源文件夹中的图像复制到剪贴板管理器,以便稍后粘贴到另一个应用程序上,如邮件、whatapp或聊天。我有几个研究人员的链接,有些人提到这可以做一个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);发布于 2012-11-28 15:37:04
尝试将这两行代码添加到代码的末尾。
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setPrimaryClip(theClip);https://stackoverflow.com/questions/13599162
复制相似问题