- Home /
Inherit class from AndroidJavaObject
Hi, I have a class defined like this:
public class JavaIntent : AndroidJavaObject {
public JavaIntent () : base("android.content.Intent")
{
}
}
And using it like:
public static void StartIntentChooser(JavaIntent intent)
{
var player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = player.GetStatic<AndroidJavaObject>("currentActivity");
activity.Call("startActivity", intent);
}
I'm trying to make wrappers to Android SDK's classes, but I'm getting this error:
JNI: Unknown signature for type 'JavaIntent' (obj = JavaIntent) instance
Does any one have a clue of what's going on?
Thanks, Martín.
EDIT
Inspecting the assmebly browser I found that calls to AndroidJavaObject make a type check like this one:
if (typeof(ReturnType) == typeof(AndroidJavaObject))
{
IntPtr jobject = AndroidJNI.CallObjectMethod (this.m_jobject, cachedMethodID, args2);
return (ReturnType)new AndroidJavaObject (jobject);
}
My JavaIntent class, derived from AndroidJavaObject doesn't pass this check.
I thought about making a custom AndroidJavaObject class, but that may be hard. Does any one have a better approach?
Thanks again, Martín.
Hi, did you solve the issue? I have same problem as well
Answer by UnitedMG · Jun 04 at 09:22 PM
I tried to get working something similar but gave up eventually because of various strange runtime errors. Although AndroidJavaObject can technically be subclassed, it seems to me that it was not designed to be subclassed.
Your answer
Follow this Question
Related Questions
What is the difference between AndroidJavaClass.Call and AndroidJavaObject.Call 2 Answers
Call non-static method (from subclass) in Java from Unity 1 Answer
Callback from native Java to Unity's C# script has some weird (latency?) issue 0 Answers
Returning byte array from Java/Android 3 Answers
AndroidJavaObject.Call fails with 'method not found' 1 Answer