So I have been through the posts on stackoverflow and there is no real mention of how to copy actual image data to a clipboard. I can copy the uri to the clipboard like so:
ContentValues values = new ContentValues(2);
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg");
values.put(MediaStore.Images.Media.DATA, android.os.Environment.getExternalStorageDirectory() + path);
ContentResolver theContent = getContentResolver();
Uri imageUri = theContent.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
ClipData theClip = ClipData.newUri(getContentResolver(),"Image", imageUri);
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setPrimaryClip(theClip);
This lets me paste the uri afterwards, which is pretty worthless in most contexts unless you control the activity.
I can also send the image data to the intent directly like so:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
sendIntent.putExtra("thread_id", (long) 1);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.setType("image/*");
startActivity(sendIntent);
While this is useful, I can clearly see that pasting images to the clipboard is possible by going to the gallery and selecting "copy to clipboard" in the dropdown. This lets me paste said image to the messenger, email, chat, etc. The same seems to also be possible on most Android browsers starting 4.4.2. Is there any working code that anyone can point me to or pointers to get image data actually copied to the keyboard and not just the uri? I can see that it's possible and I'm kind of running out of ideas at this point.
Here is a valid example of a uri I am using: "content://media/external/images/media/63"