添加PNG在android的剪贴板 [英] Adding a png to clipboard in android
问题描述
我有以下code:
File imageFile = new File(f.getAbsolutePath());
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);
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setPrimaryClip(theClip);
我只看到剪贴板中的路径
不是图片
本身,我想它一定可以看到在图片
,因为当你把你看到的图像在剪贴板中的截图。也许这只是一个位图,如果你知道如何将一个位图传递到剪贴板,请告诉我们。
如果任何人可以提出一个解决方案,我将非常感激。
I only see the path in the clipboard
not the image
itself, i think it must be possible to see the image
because when you take a screenshot you see the image in the clipboard. Maybe it's only with a bitmap if you know how to pass a bitmap to the clipboard please tell.
If any one can suggest a solution i will be very thankful.
推荐答案
Android的剪贴板工作,从它的同行一样在Mac OS纸板和Windows的剪贴板上略有不同。 Mac和Windows的方法是物理存储的内容像图像/二进制,RTF,文件引用,等等,这样的数据可以在系统内共享。 Android的剪贴板只能存储文本(可与自果冻豆HTML处理)。其他类型的重新由一个内容提供者的URI指向实际数据psented $ P $。它是在App的工作接收该URI来检索其内容(通过ContentResolver的),并相应地处理接收的数据。
Android Clipboard works slightly different from its counterparts like the Mac OS PasteBoard and Windows's Clipboard. Mac and Windows approach is to physically store contents like Image/Binary, RTF, File references, etc., so data can be shared within the system. The Android clipboard can store only text (and can deal with HTML since Jelly Bean). Other types are represented by a Content Provider URI pointing to the actual data. It is job of the App receiving the URI to retrieve its contents (via ContentResolver) and treat the incoming data accordingly.
这篇关于添加PNG在android的剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!