Hi, All,
I’ve not had much experience to play around with the JNI bridge. Now I have a problem that not being able to pass a customized Class to a Java method. What I need to achieve is basically pass the info from C# to the method in the Android Java Class. Thank you.
private AndroidJavaClass ajc;
private AndroidJavaObject ajo;
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaClass videoObj = new AndroidJavaClass("com.example.sdk.VidoSchema);
ajo = jc.GetStatic<AndroidJavaObject>("currentActivity");
ajc = new AndroidJavaClass("com.example.sdk.ExampleSDK");
How to pass the VidoSchema object to the method in java file?
ajc.CallStatic("lanuchSDKMethod", ajo, SERIAL,videoObj);
Also, how to pass the arraylist of this VidoSchema class?
ArrayList<VidoSchema> videoObjArrayList;
ajc.CallStatic("lanuchSDKMethod", ajo, SERIAL,videoObjArrayList);
In java ExampleSDK file, I have methods:
public static void lanuchSDKMethod(Activity activity, String serialKey, VidoSchema cArrayList) {
...
...
}
public static void lanuchSDKMethod(Activity activity, String serialKey, ArrayList<VidoSchema> cArrayList) {
...
...
}
**This is the data structure file:**
public class VidoSchema implements Parcelable {
public boolean isEntryVideo;
public String branchId;
public String video_location;
public String xml_location;
public String subtitle_location;
public String assets_folder;
public VidoSchema(Parcel in) {
isEntryVideo = in.readByte() != 0x00;
branchId = in.readString();
xml_location = in.readString();
subtitle_location = in.readString();
assets_folder = in.readString();
}
public VidoSchema() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeByte((byte) (isEntryVideo ? 0x01 : 0x00));
dest.writeString(branchId);
dest.writeString(xml_location);
dest.writeString(subtitle_location);
dest.writeString(assets_folder);
}
@SuppressWarnings("unused")
public static final Creator<VidoSchema> CREATOR = new Creator<VidoSchema>() {
@Override
public VidoSchema createFromParcel(Parcel in) {
return new VidoSchema(in);
}
@Override
public VidoSchema[] newArray(int size) {
return new VidoSchema;
}
};
}