Question by
Rekyem · Aug 22, 2016 at 08:16 AM ·
androidioscopy-paste
[Android][iOS] Copy to clipboard function
Hello guys,
I use GUIUtility.systemCopyBuffer = myString, for do a copy of my string on device : PC, Android, or iOS.
The goal is simple, allow a copy/paste !
This is work good for PC, but not for Android & iOS.
Why ?
Thanks in advance, Rekyem.
Comment
try this for android:
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject clipboard = jo.Call<AndroidJavaObject>("getSystemService","clipboard");
AndroidJavaClass clipdata = new AndroidJavaClass("android.content.ClipData");
AndroidJavaObject clipObject = clipdata.CallStatic<AndroidJavaObject>("newPlainText","label","text to copy");
clipboard.Call( "setPrimaryClip",clipObject );
Yash's response works as is if anyone is wondering! Just insert what you want to copy where it says "text to copy".
Answer by Brogan89 · Oct 31, 2017 at 02:29 AM
For anyone else stumbling across this https://github.com/sanukin39/UniClipboard
Answer by tej-pratap · Sep 27, 2017 at 09:42 PM
Any update on this, I want to implement copy-paste for iOS device in unity app.