'How does Android's image copy-paste work and can this feature be expanded/modified?

Apologies if there is already information about this. I couldn't find anything.

On Android, you can long-press an image and choose copy. On other apps, such as Messages, Discord, FB Messenger, and Twitter, the image will show up as a suggestion above the keyboard. If you tap it, it will upload the image to the text/tweet/etc. It also works when searching on Chrome - you can either select "Image you copied" or use the keyboard suggestion like with other apps. However, long-pressing the text input and selecting Paste does NOT work in any of these apps.

How does this image copy-paste function work? Is it something that could be emulated with other file types other than images, such as audio files? Can you force a file from an app to show up in the keyboard suggestions on other apps? Or, is it just a built-in feature that can't really be expanded on at all? Thanks for your help.



Solution 1:[1]

How does this image copy-paste function work?

Android has a Clipboard Framework which can be used to copy & paste content from one place to other

Is it something that could be emulated with other file types other than images, such as audio files

Android supports generic way to copy paste content, as long as the content is a standard multi-media type you can do copy paste. only prerequisite is that the both application should support the file-type.

The app you are copying the content should know how to put the data in the clipboard, and the app that you are pasting should know how to decode the content.

Android provide all information like, whats the content type and everything so what matters is both app should make use of this Clipboard framework.

Can you force a file from an app to show up in the keyboard suggestions on other apps?

You can't force it appear on top of keyboard, even a simple copied text will show only one time on top of keyboard. even though the content present on clipboard keyboard won't show it second or third time.

It's basically specific to how a keyboard app is designed, the above scenario is true for G-board at the time of writing this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sridhar S