public void GetArray_JavaLangByteArrayToSystemByteArray() { var byteObjectArray = new Java.Lang.Byte[] { new Java.Lang.Byte(1), new Java.Lang.Byte(2), new Java.Lang.Byte(3), }; byte[] byteArray = JNIEnv.GetArray <byte>(byteObjectArray); AssertArrays("GetArray: Java.Lang.Byte[]->byte[]", byteArray, (byte)1, (byte)2, (byte)3); }
public sbyte GetAsByte(string key) { if (id_getAsByte_Ljava_lang_String_ == IntPtr.Zero) id_getAsByte_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "getAsByte", "(Ljava/lang/String;)Ljava/lang/Byte;"); IntPtr jkey = JNIEnv.NewString (key); try { using (var ret = new Java.Lang.Byte (JNIEnv.CallObjectMethod (Handle, id_getAsByte_Ljava_lang_String_, new JValue (jkey)), JniHandleOwnership.TransferLocalRef | JniHandleOwnership.DoNotRegister)) return (sbyte) ret; } finally { JNIEnv.DeleteLocalRef (jkey); } }
public void Put(string key, sbyte value) { if (id_put_Ljava_lang_String_Ljava_lang_Byte_ == IntPtr.Zero) { id_put_Ljava_lang_String_Ljava_lang_Byte_ = JNIEnv.GetMethodID(class_ref, "put", "(Ljava/lang/String;Ljava/lang/Byte;)V"); } IntPtr jkey = JNIEnv.NewString(key); try { using (var val = new Java.Lang.Byte(value)) JNIEnv.CallVoidMethod(Handle, id_put_Ljava_lang_String_Ljava_lang_Byte_, new JValue(jkey), new JValue(val)); } finally { JNIEnv.DeleteLocalRef(jkey); } }
public sbyte GetAsByte(string key) { if (id_getAsByte_Ljava_lang_String_ == IntPtr.Zero) { id_getAsByte_Ljava_lang_String_ = JNIEnv.GetMethodID(class_ref, "getAsByte", "(Ljava/lang/String;)Ljava/lang/Byte;"); } IntPtr jkey = JNIEnv.NewString(key); try { using (var ret = new Java.Lang.Byte(JNIEnv.CallObjectMethod(Handle, id_getAsByte_Ljava_lang_String_, new JValue(jkey)), JniHandleOwnership.TransferLocalRef | JniHandleOwnership.DoNotRegister)) return((sbyte)ret); } finally { JNIEnv.DeleteLocalRef(jkey); } }
public void Put(string key, sbyte value) { if (id_put_Ljava_lang_String_Ljava_lang_Byte_ == IntPtr.Zero) id_put_Ljava_lang_String_Ljava_lang_Byte_ = JNIEnv.GetMethodID (class_ref, "put", "(Ljava/lang/String;Ljava/lang/Byte;)V"); IntPtr jkey = JNIEnv.NewString (key); try { using (var val = new Java.Lang.Byte (value)) JNIEnv.CallVoidMethod (Handle, id_put_Ljava_lang_String_Ljava_lang_Byte_, new JValue (jkey), new JValue (val)); } finally { JNIEnv.DeleteLocalRef (jkey); } }