- Home /
CreateJavaRuntime problem
Hello
I have a code:
public static void Run()
{
Debug.LogWarning("isOK");
}
public static void Open()
{
AndroidJNI.AttachCurrentThread();
using ( AndroidJavaClass unityPlayer = new AndroidJavaClass( "com.unity3d.player.UnityPlayer" ) )
{
using ( AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>( "currentActivity" ) )
{
Debug.LogWarning("1");
System.IntPtr runOnUiThread =
AndroidJNI.GetMethodID(activity.GetRawClass(), "runOnUiThread", "(Ljava/lang/Runnable;)V");
System.IntPtr runnable = AndroidJNIHelper.CreateJavaRunnable(Run);
AndroidJNI.CallVoidMethod(
activity.GetRawObject(),
runOnUiThread,
AndroidJNIHelper.CreateJNIArgArray( new object[]{ runnable } )
);
Debug.LogWarning("2");
}
}
}
Everything compiles and runs. But I do not see the message "isOK" in the log, they do not call the Run method. What could be wrong?
Comment
Your answer
Follow this Question
Related Questions
Getting byte[] or ByteBuffer[] from native Java 1 Answer
Just how slow is the JNI? 0 Answers
I need a local push function. so I made it using alrammanager. but it doesn't 0 Answers
An working example of calling Native C code from a C# script in Android 0 Answers
Using AndroidJavaObject.CallStatic to retrieve a return value 0 Answers