Hi there
I 'd like to get “test” text from clipbord.
I created Java code. and compiled and get UnityAndroidPlugin.jar file.
and I put it onto /Plugins/Android folder
UnityAndroidPlugin.java
package com.you;
import com.unity3d.player.UnityPlayerActivity;
import android.content.Context;
import android.text.ClipboardManager;
public class UnityAndroidPlugin extends UnityPlayerActivity {
private static UnityAndroidPlugin m_instance;
public static UnityAndroidPlugin instance() {
if (m_instance == null)
m_instance = new UnityAndroidPlugin();
return m_instance;
}
private UnityAndroidPlugin () {
}
public void getCode() {
ClipboardManager cm = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
cm.setText("hoge"); // I wanna get hoge text from clipbord.
}
}
I also create C# code below
UnityAndroidPlugin.cs
using UnityEngine;
using System.Collections;
using System.IO;
#if UNITY_ANDROID
public class UnityAndroidPlugin
{
// Logs the user out and invalidates the token
public static void getCode ()
{
if (Application.platform != RuntimePlatform.Android)
return;
var pluginClass = new AndroidJavaClass("com.you.UnityAndroidPlugin") ;
AndroidJavaObject plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
plugin.Call("getCode");
plugin.Dispose();
pluginClass.Dispose();
}
}
#endif
and i called
UnityAndroidPlugin.getCode();
but my Android suspended… why can’t?
could you help me??