android developer
android developer

Reputation: 115952

Is it possible to copy&paste image data to the clipboard, like on desktop OSs?

On desktop OSs, in image-editing apps, you can copy a part of the image and then go to another app and paste it.

Is it also possible and officially supported on Android?

If so, what are the capabilities of such a feature? is there a limit to the number of pixels, for example, that can be copied?

All I've found is that those are the types of data (link here):

Text - A text string. You put the string directly into the clip object, which you then put onto the clipboard. To paste the string, you get the clip object from the clipboard and copy the string to into your application's storage.

URI - A Uri object representing any form of URI. This is primarily for copying complex data from a content provider. To copy data, you put a Uri object into a clip object and put the clip object onto the clipboard. To paste the data, you get the clip object, get the Uri object, resolve it to a data source such as a content provider, and copy the data from the source into your application's storage.

Intent - An Intent. This supports copying application shortcuts. To copy data, you create an Intent, put it into a clip object, and put the clip object onto the clipboard. To paste the data, you get the clip object and then copy the Intent object into your application's memory area.

Upvotes: 0

Views: 845

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93668

Not easily. There is no direct way to paste image data. You may be able to do it like this though:

1)Create a clip with a URI. You'll need to define a URI to that part of the photo 2)Write a content provider which provides an image MIME type.
3)Have the content provider pass along the data you wanted to paste when the URI from part 1 is requested.

It will obviously not work in all apps, as the paster needs to be able to understand and expect the image MIME type for a clip data URI. Most apps won't would be my guess.

Upvotes: 1

Related Questions