Adding png to clipboard in android

I have the following 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 see only the path in the clipboard not the image itself, I think it should be possible to see the image , because when you take a screenshot, you see the image on the clipboard. Maybe this is only with a bitmap, if you know how to transfer the bitmap to the clipboard, please tell me. If anyone can suggest a solution, I will be very grateful.

+4
source share
1 answer

Android Clipboard works slightly different than its counterparts, such as Mac OS PasteBoard and Windows Clipboard. The Mac and Windows approach is to physically store content such as Image / Binary, RTF, file links, etc. Therefore, the data can be shared on the system. The Android clipboard can only store text (and can process HTML with Jelly Bean). Other types are content provider URIs that indicate actual data. This is the job of the application receiving the URI to retrieve its contents (via the ContentResolver) and process the incoming data accordingly.

0
source

All Articles