How to get the text from android clipboard?

I want to copy some text from my email (or any other app outside my game) and paste it into my unity game. On some devices, when you tap and hold, the clipboard will show. But on some it doesn’t. So now, I want to automatically get the text from the clipboard instead of having the user click on paste before the text shows.

If anyone has a better idea then I would appreciate that also. Thanks.

You may want to use AndroidJava* APIs Unity - Scripting API: AndroidJavaObject to call Java methods in ClipboardManager  |  Android Developers

i ended up making a plugin. i would post the solution but the real problem is actually making a plugin.

i don’t think you can simple use th androidjava apis for this. because there are two ways to get the clipboard. one work only for pre honeycomb and the other works only for honeycomb and after.

I found that UniClipboard (open source – MIT license) is a simple solution. Add it to your project, and you just need one line to read the clipboard text (and you can also set the clipboard text too):

GitHub - sanukin39/UniClipboard: Simple clipboard plugin for unity