- Home /
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.
Answer by Yury-Habets · Jan 04, 2016 at 08:38 AM
You may want to use AndroidJava* APIs http://docs.unity3d.com/ScriptReference/AndroidJavaObject.html to call Java methods in http://developer.android.com/reference/android/content/ClipboardManager.html
Answer by paolo_lionhg · Jan 04, 2016 at 02:48 PM
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.
Answer by mischinab · Jun 01, 2019 at 11:38 AM
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):
Your answer
Follow this Question
Related Questions
Writing int values to the texts, but its not working on phone 1 Answer
Boldface not working well on android 1 Answer
TouchScreenKeyboard swipe text 0 Answers
Adjusting UI to cellphone screen size 0 Answers
How to keep opening of keyboard when focus transferred to another input field by programmatically.? 0 Answers