public List <Breadcrumb> GetBreadcrumbs() { List <Breadcrumb> breadcrumbs = new List <Breadcrumb>(); if (!CanRunJNI()) { return(breadcrumbs); } bool isAttached = bsg_unity_isJNIAttached(); if (!isAttached) { AndroidJNI.AttachCurrentThread(); } var javaBreadcrumbs = CallNativeObjectMethod("getBreadcrumbs", "()Ljava/util/List;", new object[] {}); var iterator = AndroidJNI.CallObjectMethod(javaBreadcrumbs, CollectionIterator, new jvalue[] {}); while (AndroidJNI.CallBooleanMethod(iterator, IteratorHasNext, new jvalue[] {})) { var crumb = AndroidJNI.CallObjectMethod(iterator, IteratorNext, new jvalue[] {}); breadcrumbs.Add(ConvertToBreadcrumb(crumb)); AndroidJNI.DeleteLocalRef(crumb); } AndroidJNI.DeleteLocalRef(javaBreadcrumbs); AndroidJNI.DeleteLocalRef(iterator); if (!isAttached) { AndroidJNI.DetachCurrentThread(); } return(breadcrumbs); }
public static AndroidJavaObject ConvertFromHashSetStringToSetAndroidJavaObject(ISet <string> objSet) { if (objSet != null) { var hashSetJavaObject = new AndroidJavaObject("java.util.HashSet"); //IntPtr methodPut = AndroidJNIHelper.GetMethodID( // hashSetJavaObject.GetRawClass(), // "add", // "(Ljava/lang/String)Ljava/lang/Boolean;"); IntPtr methodPut = AndroidJNIHelper.GetMethodID( hashSetJavaObject.GetRawClass(), "add", "(Ljava/lang/String);"); foreach (var item in objSet) { var itemJavaObject = new AndroidJavaObject("java.lang.String", item); var args = new object[1]; args[0] = itemJavaObject; AndroidJNI.CallBooleanMethod(hashSetJavaObject.GetRawObject(), methodPut, AndroidJNIHelper.CreateJNIArgArray(args)); } return(hashSetJavaObject); } return(null); }
public bool has(string name) { #if VERBOSE_LOGGING Debug.Log(MethodBase.GetCurrentMethod().Name); #endif JNIFind(); if (_jcJsonObject == IntPtr.Zero) { Debug.LogError("_jcJsonObject is not initialized"); return(false); } if (_jmHas == IntPtr.Zero) { Debug.LogError("_jmHas is not initialized"); return(false); } IntPtr arg1 = AndroidJNI.NewStringUTF(name); bool result = AndroidJNI.CallBooleanMethod(_instance, _jmHas, new jvalue[] { new jvalue() { l = arg1 } }); AndroidJNI.DeleteLocalRef(arg1); return(result); }
public void setCustomUrlSchemes(List <string> schemes) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown AndroidJavaClass val = new AndroidJavaClass("net.gogame.gowrap.sdk.GoWrap"); try { AndroidJavaObject val2 = new AndroidJavaObject("java.util.ArrayList", new object[0]); IntPtr methodID = AndroidJNIHelper.GetMethodID(val2.GetRawClass(), "add", "(Ljava/lang/Object;)Z"); object[] array = new object[1]; foreach (string scheme in schemes) { string text = (string)(array[0] = scheme); AndroidJNI.CallBooleanMethod(val2.GetRawObject(), methodID, AndroidJNIHelper.CreateJNIArgArray(array)); } val.CallStatic("setCustomUrlSchemes", new object[1] { val2 }); } finally { ((IDisposable)val)?.Dispose(); } }
public void compress(Bitmap.CompressFormat format, int quality, ByteArrayOutputStream stream) { JNIFind(); if (_instance == IntPtr.Zero) { Debug.LogError("_instance is not initialized"); return; } if (_jmCompress == IntPtr.Zero) { Debug.LogError("_jmCompress is not initialized"); return; } AndroidJNI.CallBooleanMethod(_instance, _jmCompress, new jvalue[] { new jvalue() { l = format.Instance }, new jvalue() { i = quality }, new jvalue() { l = stream.GetInstance() } }); }
// Supposed to be called once at voice initialization. // Otherwise recreate native object (instead of adding 'set callback' method to java interface) public void SetCallback(Action <short[]> callback, Voice.LocalVoice localVoice) { if (audioIn != null) { Dispose(); } var voiceFrameSize = ((Voice.LocalVoiceFramed)localVoice).FrameSize; // setting to voice FrameSize lets to avoid framing procedure javaBuf = AndroidJNI.NewGlobalRef(AndroidJNI.NewShortArray(voiceFrameSize)); this.callback = new DataCallback(callback, javaBuf); audioIn = new AndroidJavaObject("com.exitgames.photon.audioinaec.AudioInAEC"); bool aecAvailable = audioIn.Call <bool>("AECIsAvailable"); int minBufSize = audioIn.Call <int>("GetMinBufferSize", SamplingRate, Channels); Debug.LogFormat("AndroidAudioInAEC: AndroidJavaObject created: aecAvailable: {0}, minBufSize: {1}", aecAvailable, minBufSize); AndroidJavaClass app = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = app.GetStatic <AndroidJavaObject>("currentActivity"); // Set buffer IntPtr reference separately via pure jni call, pass other values and start capture via AndroidJavaObject helper var meth = AndroidJNI.GetMethodID(audioIn.GetRawClass(), "SetBuffer", "([S)Z"); bool ok = AndroidJNI.CallBooleanMethod(audioIn.GetRawObject(), meth, new jvalue[] { new jvalue() { l = javaBuf } }); if (ok) { ok = audioIn.Call <bool>("Start", activity, this.callback, SamplingRate, Channels, minBufSize * 4, aecAvailable); } Debug.LogFormat("AndroidAudioInAEC: AndroidJavaObject started: {0}, buffer size: {1}, sampling rate: {2}, channels: {3}, record buffer size: {4}, aec: {5}", ok, voiceFrameSize, SamplingRate, Channels, minBufSize * 4, aecAvailable); }
private Dictionary <string, object> DictionaryFromJavaMap(IntPtr source) { var dict = new Dictionary <string, object>(); var entries = AndroidJNI.CallObjectMethod(source, MapEntrySet, new jvalue[] {}); var iterator = AndroidJNI.CallObjectMethod(entries, CollectionIterator, new jvalue[] {}); while (AndroidJNI.CallBooleanMethod(iterator, IteratorHasNext, new jvalue[] {})) { var entry = AndroidJNI.CallObjectMethod(iterator, IteratorNext, new jvalue[] {}); var key = AndroidJNI.CallStringMethod(entry, MapEntryGetKey, new jvalue[] {}); var value = AndroidJNI.CallObjectMethod(entry, MapEntryGetValue, new jvalue[] {}); if (value != null && value != IntPtr.Zero) { var valueClass = AndroidJNI.CallObjectMethod(value, ObjectGetClass, new jvalue[] {}); if (AndroidJNI.CallBooleanMethod(valueClass, ClassIsArray, new jvalue[] {})) { var values = AndroidJNIHelper.ConvertFromJNIArray <string[]>(value); dict.AddToPayload(key, values); } else if (AndroidJNI.IsInstanceOf(value, MapClass)) { dict.AddToPayload(key, DictionaryFromJavaMap(value)); } else { // FUTURE(dm): check if Integer, Long, Double, or Float before calling toString dict.AddToPayload(key, AndroidJNI.CallStringMethod(value, ObjectToString, new jvalue[] {})); } AndroidJNI.DeleteLocalRef(value); } AndroidJNI.DeleteLocalRef(entry); } return(dict); }
int makeJNICall(string method, string caption, string message, string[] buttons) { if (isMobileRuntime == false) { return(0); } #if UNITY_ANDROID AndroidJavaObject obj_ArrayList = new AndroidJavaObject("java.util.ArrayList"); Debug.Log("unity message: " + message); jvalue val = new jvalue(); val.l = AndroidJNI.NewStringUTF(message); IntPtr method_Add = AndroidJNIHelper.GetMethodID(obj_ArrayList.GetRawClass(), "add", "(Ljava/lang/Object;)Z"); foreach (string button in buttons) { AndroidJNI.CallBooleanMethod(obj_ArrayList.GetRawObject(), method_Add, AndroidJNIHelper.CreateJNIArgArray(new string[] { button })); } return(_pluginObject.Call <int>(method, caption, message, obj_ArrayList, "NativeDialogs")); #else return(0); #endif }
public T InvokeCall <T>(string name, string sig, params object[] args) { T local; Type type = typeof(T); IntPtr methodID = AndroidJNI.GetMethodID(this.RawClass, name, sig); if (methodID == IntPtr.Zero) { Debug.LogError("Cannot get method for " + name); throw new Exception("Cannot get method for " + name); } jvalue[] jvalueArray = ConstructArgArray(args); try { if (type == typeof(bool)) { return((T)AndroidJNI.CallBooleanMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(string)) { return((T)AndroidJNI.CallStringMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(int)) { return((T)AndroidJNI.CallIntMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(float)) { return((T)AndroidJNI.CallFloatMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(double)) { return((T)AndroidJNI.CallDoubleMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(byte)) { return((T)AndroidJNI.CallByteMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(char)) { return((T)AndroidJNI.CallCharMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(long)) { return((T)AndroidJNI.CallLongMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(short)) { return((T)AndroidJNI.CallShortMethod(this.raw, methodID, jvalueArray)); } local = this.InvokeObjectCall <T>(name, sig, args); } finally { AndroidJNIHelper.DeleteJNIArgArray(args, jvalueArray); } return(local); }
public static bool CallBooleanMethod(IntPtr obj, IntPtr methodId, jvalue[] args) { try { return(AndroidJNI.CallBooleanMethod(obj, methodId, args)); } finally { CheckException(); } }
protected override void initParamsFromAndroidJavaObject(AndroidJavaObject instance) { base.initParamsFromAndroidJavaObject(instance); this.creativeType = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getCreativeType", "()Ljava/lang/String"), new jvalue[0] { }); this.skipText = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getSkipText", "()Ljava/lang/String"), new jvalue[0] { }); this.autoPlay = AndroidJNI.CallBooleanMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "isAutoPlay", "()Z"), new jvalue[0] { }); }
public bool IsLiveBroadcastSupported() { if (this.androidBridge == IntPtr.Zero) { UnityEngine.Debug.LogError("androidBridge is null, cann't get liveBroadcast support!"); return(false); } jvalue[] args = new jvalue[0]; return(AndroidJNI.CallBooleanMethod(this.androidBridge, QGameKitAndroidBridge.isLiveBroadcastSupportedMethodID, args)); }
public bool StopLiveBroadcast() { if (this.androidBridge == IntPtr.Zero) { UnityEngine.Debug.LogError("androidBridge is null, stop liveBroadcast failed!"); return(false); } jvalue[] args = new jvalue[0]; return(AndroidJNI.CallBooleanMethod(this.androidBridge, QGameKitAndroidBridge.stopLiveBroadcastMethodID, args)); }
public T InvokeCall <T>(string name, string sig, params object[] args) { System.Type type = typeof(T); IntPtr objectClass = AndroidJNI.GetObjectClass(this.raw); IntPtr methodID = AndroidJNI.GetMethodID(objectClass, name, sig); jvalue[] jvalueArray = ConstructArgArray(args); if (objectClass == IntPtr.Zero) { Debug.LogError("Cannot get rawClass object!"); throw new Exception("Cannot get rawClass object"); } if (methodID == IntPtr.Zero) { Debug.LogError("Cannot get method for " + name); throw new Exception("Cannot get method for " + name); } if (type == typeof(bool)) { return((T)AndroidJNI.CallBooleanMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(string)) { return((T)AndroidJNI.CallStringMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(int)) { return((T)AndroidJNI.CallIntMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(float)) { return((T)AndroidJNI.CallFloatMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(double)) { return((T)AndroidJNI.CallDoubleMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(byte)) { return((T)AndroidJNI.CallByteMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(char)) { return((T)AndroidJNI.CallCharMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(long)) { return((T)AndroidJNI.CallLongMethod(this.raw, methodID, jvalueArray)); } if (type == typeof(short)) { return((T)AndroidJNI.CallShortMethod(this.raw, methodID, jvalueArray)); } return(this.InvokeObjectCall <T>(name, sig, args)); }
private static AndroidJavaObject GetArrayListString(List <string> list) { AndroidJavaObject arrayList = new AndroidJavaObject("java.util.ArrayList"); var add = AndroidJNIHelper.GetMethodID(arrayList.GetRawClass(), "add", "(Ljava/lang/String;)Z;", false); foreach (string val in list) { AndroidJNI.CallBooleanMethod(arrayList.GetRawObject(), add, AndroidJNIHelper.CreateJNIArgArray(new object[] { val })); } return(arrayList); }
private AndroidJavaObject convertMetadataToJavaHashMap(Dictionary <string, object> metaMap) { AndroidJavaObject meta_Hashmap = new AndroidJavaObject("java.util.HashMap"); if (metaMap != null) { IntPtr method_MetaPut = AndroidJNIHelper.GetMethodID(meta_Hashmap.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); object[] meta_args = new object[2]; meta_args[0] = meta_args[1] = null; foreach (KeyValuePair <string, object> metaKvp in metaMap) { meta_args[0] = new AndroidJavaObject("java.lang.String", metaKvp.Key); if (metaKvp.Value.GetType().ToString() == "System.String") { if (metaKvp.Value != null && metaKvp.Value.Equals("yes") || metaKvp.Value.Equals("no")) { string value = metaKvp.Value.Equals("yes") ? "true" : "false"; meta_args[1] = new AndroidJavaObject("java.lang.Boolean", value); } else { meta_args[1] = new AndroidJavaObject("java.lang.String", metaKvp.Value); } } else if (metaKvp.Key == HelpshiftSdk.HSTAGSKEY && metaKvp.Value.GetType().ToString() == "System.String[]") { string[] tagsArray = (string[])metaKvp.Value; AndroidJavaObject tags_ArrayList = new AndroidJavaObject("java.util.ArrayList"); IntPtr method_add = AndroidJNIHelper.GetMethodID(tags_ArrayList.GetRawClass(), "add", "(Ljava/lang/String;)Z"); object[] tags_args = new object[1]; foreach (string tag in tagsArray) { if (tag != null) { tags_args[0] = new AndroidJavaObject("java.lang.String", tag); AndroidJNI.CallBooleanMethod(tags_ArrayList.GetRawObject(), method_add, AndroidJNIHelper.CreateJNIArgArray(tags_args)); } } meta_args[1] = new AndroidJavaObject("java.util.ArrayList", tags_ArrayList); } if (meta_args[1] != null) { AndroidJNI.CallObjectMethod(meta_Hashmap.GetRawObject(), method_MetaPut, AndroidJNIHelper.CreateJNIArgArray(meta_args)); } } } Debug.Log("Returning the Hashmap : " + meta_Hashmap); return(meta_Hashmap); }
public bool isAdLoaded() { #if UNITY_ANDROID return(AndroidJNI.CallBooleanMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "isAdLoaded", "()Z"), new jvalue[0] { })); #elif UNITY_IPHONE return(AppnextIOSSDKBridge.adIsLoaded(adKey)); #else return(false); #endif }
public T InvokeCall <T>(string name, string sig, params object[] args) { Type t = typeof(T); IntPtr method = AndroidJNI.GetMethodID(RawClass, name, sig); jvalue[] jArgs = ConstructArgArray(args); if (method == IntPtr.Zero) { Debug.LogError("Cannot get method for " + name); throw new Exception("Cannot get method for " + name); } if (t == typeof(bool)) { return((T)(object)AndroidJNI.CallBooleanMethod(raw, method, jArgs)); } else if (t == typeof(string)) { return((T)(object)AndroidJNI.CallStringMethod(raw, method, jArgs)); } else if (t == typeof(int)) { return((T)(object)AndroidJNI.CallIntMethod(raw, method, jArgs)); } else if (t == typeof(float)) { return((T)(object)AndroidJNI.CallFloatMethod(raw, method, jArgs)); } else if (t == typeof(double)) { return((T)(object)AndroidJNI.CallDoubleMethod(raw, method, jArgs)); } else if (t == typeof(byte)) { return((T)(object)AndroidJNI.CallByteMethod(raw, method, jArgs)); } else if (t == typeof(char)) { return((T)(object)AndroidJNI.CallCharMethod(raw, method, jArgs)); } else if (t == typeof(long)) { return((T)(object)AndroidJNI.CallLongMethod(raw, method, jArgs)); } else if (t == typeof(short)) { return((T)(object)AndroidJNI.CallShortMethod(raw, method, jArgs)); } else { return(InvokeObjectCall <T>(name, sig, args)); } }
private static AndroidJavaObject GetArrayList(List <object> list) { AndroidJavaObject arrayList = new AndroidJavaObject("java.util.ArrayList"); var add = AndroidJNIHelper.GetMethodID(arrayList.GetRawClass(), "add", "(Ljava/lang/Object;)Z;", false); foreach (object val in list) { AndroidJavaObject javaObject = GetJavaObject(val); AndroidJNI.CallBooleanMethod(arrayList.GetRawObject(), add, AndroidJNIHelper.CreateJNIArgArray(new object[] { javaObject })); } return(arrayList); }
protected override void initParamsFromAndroidJavaObject(AndroidJavaObject instance) { base.initParamsFromAndroidJavaObject(instance); this.progressType = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getProgressType", "()Ljava/lang/String"), new jvalue[0] { }); this.videoLength = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getVideoLength", "()Ljava/lang/String"), new jvalue[0] { }); this.progressColor = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getProgressColor", "()Ljava/lang/String"), new jvalue[0] { }); this.delay = AndroidJNI.CallLongMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getCloseDelay", "()J"), new jvalue[0] { }); this.showClose = AndroidJNI.CallBooleanMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "isShowClose", "()Z"), new jvalue[0] { }); }
private void __fillArrayList(string[] ids) { AndroidJNI.CallVoidMethod(arraylist.GetRawObject(), ptrMethodClear, AndroidJNIHelper.CreateJNIArgArray(new object[0])); object[] args = new object[1]; foreach (string id in ids) { using (AndroidJavaObject jstring = new AndroidJavaObject("java.lang.String", id)) { args[0] = jstring; AndroidJNI.CallBooleanMethod(arraylist.GetRawObject(), ptrMethodAdd, AndroidJNIHelper.CreateJNIArgArray(args)); } } }
private bool setup() { if (this.androidBridge == IntPtr.Zero) { UnityEngine.Debug.LogError("androidBridge is null, setup failed!"); return(false); } QGameKitAndroidBridge.UserAccountCallback userAccountCallback = new QGameKitAndroidBridge.UserAccountCallback(QGameKitAndroidBridge.userAccountDelegate); jvalue[] args = AndroidJNIHelper.CreateJNIArgArray(new object[] { userAccountCallback }); return(AndroidJNI.CallBooleanMethod(this.androidBridge, QGameKitAndroidBridge.setupMethodID, args)); }
public T InvokeCall <T>(string name, string sig, params object[] args) { Type t = typeof(T); IntPtr rawClass = AndroidJNI.GetObjectClass(raw); IntPtr method = AndroidJNI.GetMethodID(rawClass, name, sig); jvalue[] jArgs = ConstructArgArray(args); if (t == typeof(bool)) { return((T)(object)AndroidJNI.CallBooleanMethod(raw, method, jArgs)); } else if (t == typeof(string)) { return((T)(object)AndroidJNI.CallStringMethod(raw, method, jArgs)); } else if (t == typeof(int)) { return((T)(object)AndroidJNI.CallIntMethod(raw, method, jArgs)); } else if (t == typeof(float)) { return((T)(object)AndroidJNI.CallFloatMethod(raw, method, jArgs)); } else if (t == typeof(double)) { return((T)(object)AndroidJNI.CallDoubleMethod(raw, method, jArgs)); } else if (t == typeof(byte)) { return((T)(object)AndroidJNI.CallByteMethod(raw, method, jArgs)); } else if (t == typeof(char)) { return((T)(object)AndroidJNI.CallCharMethod(raw, method, jArgs)); } else if (t == typeof(long)) { return((T)(object)AndroidJNI.CallLongMethod(raw, method, jArgs)); } else if (t == typeof(short)) { return((T)(object)AndroidJNI.CallShortMethod(raw, method, jArgs)); } else { return(InvokeObjectCall <T>(name, sig, args)); } }
private Breadcrumb ConvertToBreadcrumb(IntPtr javaBreadcrumb) { var metadata = new Dictionary <string, string>(); IntPtr javaMetadata = AndroidJNI.CallObjectMethod(javaBreadcrumb, BreadcrumbGetMetadata, new jvalue[] {}); IntPtr entries = AndroidJNI.CallObjectMethod(javaMetadata, MapEntrySet, new jvalue[] {}); AndroidJNI.DeleteLocalRef(javaMetadata); IntPtr iterator = AndroidJNI.CallObjectMethod(entries, CollectionIterator, new jvalue[] {}); AndroidJNI.DeleteLocalRef(entries); while (AndroidJNI.CallBooleanMethod(iterator, IteratorHasNext, new jvalue[] {})) { IntPtr entry = AndroidJNI.CallObjectMethod(iterator, IteratorNext, new jvalue[] {}); IntPtr key = AndroidJNI.CallObjectMethod(entry, MapEntryGetKey, new jvalue[] {}); IntPtr value = AndroidJNI.CallObjectMethod(entry, MapEntryGetValue, new jvalue[] {}); AndroidJNI.DeleteLocalRef(entry); if (key != IntPtr.Zero && value != IntPtr.Zero) { metadata.Add(AndroidJNI.GetStringUTFChars(key), AndroidJNI.GetStringUTFChars(value)); } AndroidJNI.DeleteLocalRef(key); AndroidJNI.DeleteLocalRef(value); } AndroidJNI.DeleteLocalRef(iterator); IntPtr type = AndroidJNI.CallObjectMethod(javaBreadcrumb, BreadcrumbGetType, new jvalue[] {}); string typeName = AndroidJNI.CallStringMethod(type, ObjectToString, new jvalue[] {}); AndroidJNI.DeleteLocalRef(type); string name = "<empty>"; IntPtr nameObj = AndroidJNI.CallObjectMethod(javaBreadcrumb, BreadcrumbGetName, new jvalue[] {}); if (nameObj != IntPtr.Zero) { name = AndroidJNI.GetStringUTFChars(nameObj); } AndroidJNI.DeleteLocalRef(nameObj); string timestamp = AndroidJNI.CallStringMethod(javaBreadcrumb, BreadcrumbGetTimestamp, new jvalue[] {}); return(new Breadcrumb(name, timestamp, typeName, metadata)); }
public override bool IsBuffering() { bool result = false; if (m_Video != null) { if (m_Method_IsBuffering != System.IntPtr.Zero) { result = AndroidJNI.CallBooleanMethod(m_Video.GetRawObject(), m_Method_IsBuffering, m_Value0); } else { result = m_Video.Call <bool>("IsBuffering"); } } return(result); }
public override bool HasAudio() { bool result = false; if (m_Video != null) { if (m_Method_HasAudio != System.IntPtr.Zero) { result = AndroidJNI.CallBooleanMethod(m_Video.GetRawObject(), m_Method_HasAudio, m_Value0); } else { result = m_Video.Call <bool>("HasAudio"); } } return(result); }
protected virtual void initParamsFromAndroidJavaObject(AndroidJavaObject instance) { this.buttonText = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getButtonText", "()Ljava/lang/String"), new jvalue[0] { }); this.buttonColor = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getButtonColor", "()Ljava/lang/String"), new jvalue[0] { }); this.categories = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getCategories", "()Ljava/lang/String"), new jvalue[0] { }); this.postback = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getPostback", "()Ljava/lang/String"), new jvalue[0] { }); this.orientation = AndroidJNI.CallStringMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getOrientation", "()Ljava/lang/String"), new jvalue[0] { }); this.backButtonCanClose = AndroidJNI.CallBooleanMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "isBackButtonCanClose", "()Z"), new jvalue[0] { }); this.mute = AndroidJNI.CallBooleanMethod(instance.GetRawObject(), AndroidJNIHelper.GetMethodID(instance.GetRawClass(), "getMute", "()Z"), new jvalue[0] { }); }
public bool isInitialized() { JNIFind(); if (_instance == IntPtr.Zero) { Debug.LogError("_instance is not initialized"); return(false); } if (_jmIsInitialized == IntPtr.Zero) { Debug.LogError("_jmIsInitialized is not initialized"); return(false); } return(AndroidJNI.CallBooleanMethod(_instance, _jmIsInitialized, new jvalue[0] { })); }
protected internal static AndroidJavaObject GetListFromList(List <string> list) { // quick out if nothing in the dict param if (list == null || list.Count <= 0) { return(null); } AndroidJavaObject listObj = new AndroidJavaObject("java.util.ArrayList"); IntPtr methodAdd = AndroidJNIHelper.GetMethodID(listObj.GetRawClass(), "add", "(Ljava/lang/Object;)Z"); foreach (string item in list) { AndroidJNI.CallBooleanMethod(listObj.GetRawObject(), methodAdd, AndroidJNIHelper.CreateJNIArgArray(new string[] { item })); } return(listObj); }
public T InvokeCall <T>(string name, string sig, params object[] args) { Type type = typeof(T); IntPtr methodId = AndroidJNI.GetMethodID(AndroidJNI.GetObjectClass(this.raw), name, sig); jvalue[] jvalueArray = JavaObjWrapper.ConstructArgArray(args); if ((object)type == (object)typeof(bool)) { return((T)(ValueType)AndroidJNI.CallBooleanMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(string)) { return((T)AndroidJNI.CallStringMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(int)) { return((T)(ValueType)AndroidJNI.CallIntMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(float)) { return((T)(ValueType)AndroidJNI.CallFloatMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(double)) { return((T)(ValueType)AndroidJNI.CallDoubleMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(byte)) { return((T)(ValueType)AndroidJNI.CallByteMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(char)) { return((T)(ValueType)AndroidJNI.CallCharMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(long)) { return((T)(ValueType)AndroidJNI.CallLongMethod(this.raw, methodId, jvalueArray)); } if ((object)type == (object)typeof(short)) { return((T)(ValueType)AndroidJNI.CallShortMethod(this.raw, methodId, jvalueArray)); } return(this.InvokeObjectCall <T>(name, sig, args)); }