private static void _InitGSensor() { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass mjc = new AndroidJavaClass("com.innomind.belshooting.ComBleWrapper")) { Debug.Log("HanderPianoPlugin unity _InitHanderPiano() in android!! "); mjc.CallStatic("InitGSensor"); } }
private static byte[] Compress(byte[] bArray) { Debug.Log("Beginning compression"); AndroidJNI.AttachCurrentThread(); byte[] compressedArray = ByteArrayCompression.ByteArrayCompressionClass.CallStatic <byte[]> ("compress", bArray); AndroidJNI.DetachCurrentThread(); Debug.Log("Finished compressing. Result: " + bArray.Length + " bytes -> " + compressedArray.Length + " bytes"); return(compressedArray); }
private static void _onChoseToConnectDevice(int num) { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass mjc = new AndroidJavaClass("com.innomind.belshooting.ComBleWrapper")) { Debug.Log("HanderPianoPlugin unity _onChoseToConnectDevice() in android!! "); mjc.CallStatic("onChoseToConnectDevice", num); } }
private void OnSampleBuffer(float[] data) { AndroidJNI.AttachCurrentThread(); recorder.CommitSamples(data, clock?.timestamp ?? 0L); if (mute) { Array.Clear(data, 0, data.Length); } }
private static void _ClearNotifications() { Debug.Log("CLEAR NOTIFICATIONS"); AndroidJNI.AttachCurrentThread(); AndroidJavaClass pushClass = new AndroidJavaClass("com.gamedonia.pushnotifications.PushNotifications"); pushClass.CallStatic("clearNotifications", new object [] {}); }
public static double RandomValue() { AndroidJNI.AttachCurrentThread(); AndroidJNI.PushLocalFrame(0); double val = GetSkillz().CallStatic <double>("random"); AndroidJNI.PopLocalFrame(IntPtr.Zero); return(val); }
private static void _onUnityColiderEngine(bool visible) { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass mjc = new AndroidJavaClass("com.innomind.belshooting.ComBleWrapper")) { Debug.Log("HanderPianoPlugin unity _InitHanderPiano() in android!! "); mjc.CallStatic("onUnityColiderEngine", visible); } }
private void openThread() { #if UNITY_ANDROID AndroidJNI.AttachCurrentThread(); #endif try { _tcpclnt = new TcpClient(); _tcpclnt.SendTimeout = 5000; _tcpclnt.ReceiveTimeout = 10000; _tcpclnt.ReceiveBufferSize = 102400; _tcpclnt.SendBufferSize = 10240; _tcpclnt.NoDelay = true; var c = _tcpclnt.BeginConnect(ipAddress, 7766, null, null); var success = c.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3)); if (!success) { _tcpclnt.Close(); _threadOnOpenFailed = true; } _tcpclnt.EndConnect(c); _stream = _tcpclnt.GetStream(); Command command = new Command("authentication_management", "authenticate"); command.AddParameter(new Parameter("user", user)); command.AddParameter(new Parameter("password", password)); command.AddParameter(new Parameter("access_level", "1")); string str = GetSendHeader() + command.XmlWithNull; SendCommand(command, str); _stream.BeginRead(_receiveBytes, 0, _receiveBytes.Length, _messageReceivedCallback, null); _connected = true; _threadOnOpen = true; } catch (Exception e) { if (_tcpclnt != null) { _tcpclnt.Close(); } Debug.Log("OpenThread: " + e); _threadOnOpenFailed = true; } #if UNITY_ANDROID AndroidJNI.DetachCurrentThread(); #endif _openThread.Abort(); return; }
public LeanplumAndroid() { AndroidJNI.AttachCurrentThread(); nativeSdk = new AndroidJavaClass("com.leanplum.UnityBridge"); // This also constructs LeanplumUnityHelper and the game object. gameObjectName = LeanplumUnityHelper.Instance.gameObject.name; NativeSDK.CallStatic("initialize", gameObjectName, Constants.SDK_VERSION, null); }
private void OnSampleBuffer(float[] data) { AndroidJNI.AttachCurrentThread(); mediaRecorder.CommitSamples(data, clock.Timestamp); AndroidJNI.DetachCurrentThread(); if (mute) { Array.Clear(data, 0, data.Length); } }
private static void _onUnityStopScan() { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass mjc = new AndroidJavaClass("com.innomind.belshooting.ComBleWrapper")) //using(AndroidJavaClass mjc = new AndroidJavaClass("com.innomind.belshooting.ComBleWrapper")) { Debug.Log("HanderPianoPlugin unity _onUnityStopScan() in android!! "); mjc.CallStatic("onUnityStopScan"); } }
void Start() { #if UNITY_ANDROID AndroidJNI.AttachCurrentThread(); jc = new AndroidJavaClass("com.android.plava.spiderspy.CallStatusBridge"); jc.CallStatic("setCallBack", new object[2] { gameObject.name, "OnCallStateChange" }); #endif }
public void GetImageFromGallery() { loader.enableLoader(); AndroidJNI.AttachCurrentThread(); AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject profClass = new AndroidJavaObject("com.gamedonia.medical.UnityBinder"); profClass.CallStatic("OpenGallery", unity.GetStatic <AndroidJavaObject> ("currentActivity")); }
/// <summary> /// Chiama la funzione dalla libreria aar "unityutils" per riavviare il dispositivo (necessita del root) /// </summary> /// <param name="Delay">dopo quanti millisecondi deve essere riavviato il dispositivo</param> public static void Reboot(int Delay) { if (!isEditor) { new System.Threading.Thread(() => { AndroidJNI.AttachCurrentThread(); Thread.Sleep(Delay); ajo.Call("Reboot"); }).Start(); } }
public override void StartPreview(Action <Texture2D> startCallback, Action <long> frameCallback, ScreenOrientation rotation) { this.rotation = rotation != 0 ? rotation : Screen.orientation; this.callback = new Callback(startCallback, frameCallback); this.focusHandler = FocusHandler.Create(this); RenderDispatcher.Dispatch(() => { AndroidJNI.AttachCurrentThread(); device.Call(@"startPreview", (int)this.rotation, callback); }); }
private void ThreadProc() { AndroidJNI.AttachCurrentThread(); foreach (var task in m_Queue.GetConsumingEnumerable()) { TryExecuteTask(task); } AndroidJNI.DetachCurrentThread(); }
//Function to make sure the device is a Moverio BT-300. void CheckDeviceType() { if (SystemInfo.deviceModel.Equals("EPSON EMBT3C")) { AndroidJNI.AttachCurrentThread(); } else { MoverioDevice = false; } }
private async Task AddCellToGridAsync(ProcessedApp app, Transform transform, bool isRenameMode = false) { if (app.Index == -1 && string.IsNullOrEmpty(app.IconPath)) { // If we have neither app index or icon path, skip this return; } // Get app icon in background var bytesIcon = await Task.Run(() => { AndroidJNI.AttachCurrentThread(); try { return(AppProcessor.GetAppIcon(app.IconPath, app.Index)); } finally { AndroidJNI.DetachCurrentThread(); } }); // Create new instances of our app info prefabCell var newObj = (GameObject)Instantiate(this.prefabCell, transform); // Set app entry info var appEntry = newObj.GetComponent <AppEntry>(); appEntry.packageId = app.PackageName; appEntry.appName = app.AppName; appEntry.isRenameMode = isRenameMode; appEntry.installedApkIndex = app.Index; appEntry.externalIconPath = app.IconPath; // Set the icon image if (null != bytesIcon) { var texture = new Texture2D(2, 2, TextureFormat.RGBA32, false); texture.filterMode = FilterMode.Trilinear; texture.anisoLevel = 16; texture.LoadImage(bytesIcon); var rect = new Rect(0, 0, texture.width, texture.height); var image = appEntry.sprite.GetComponent <Image>(); image.sprite = Sprite.Create(texture, rect, new Vector2(0.5f, 0.5f)); // Preserve icon's aspect ratio var aspectRatioFitter = appEntry.sprite.GetComponent <AspectRatioFitter>(); aspectRatioFitter.aspectRatio = (float)texture.width / (float)texture.height; } // Set app name in text appEntry.text.text = app.AppName; }
private void AddUniqueIDs() { #if !UNITY_EDITOR string device = SystemInfo.deviceModel; int i = device.Length - 1; int io = 0; while (int.TryParse(device[i].ToString(), out io) || device[i].Equals(',') || device[i].Equals('.')) { i--; } device = device.Substring(0, i + 1); Debug.Log("DEVICE: " + device); string os = ""; string[] osSplit = SystemInfo.operatingSystem.Split(' '); if (osSplit.Length > 0) { os = osSplit[0]; } #endif #if UNITY_IPHONE && !UNITY_EDITOR && IOS_ID try { string iOSid = GetUniqueIDiOS(); if (iOSid != null && iOSid != string.Empty) { GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, iOSid, null, AutoSubmitUserInfo?GA.API.GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?SystemInfo.operatingSystem:null, "GA Unity SDK " + VERSION); } } catch { } #elif UNITY_ANDROID && !UNITY_EDITOR && ANDROID_ID try { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) { AndroidJavaClass cls_AndroidID = new AndroidJavaClass(ANDROID_CLASS_NAME + ".GA_Android"); string androidID = cls_AndroidID.CallStatic <string>("GetDeviceId"); GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, androidID, AutoSubmitUserInfo?GA.API.GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?SystemInfo.operatingSystem:null, "GA Unity SDK " + VERSION); } } } catch { } #elif UNITY_FLASH && !UNITY_EDITOR GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, null, AutoSubmitUserInfo?GA.API.GenericInfo.GetSystem():null, "Flash", AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?SystemInfo.operatingSystem:null, "GA Unity SDK " + VERSION); #elif !UNITY_EDITOR GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, null, AutoSubmitUserInfo?GA.API.GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?SystemInfo.operatingSystem:null, "GA Unity SDK " + VERSION); #endif }
private static void _StopInAppBilling() { try { AndroidJNI.AttachCurrentThread(); AndroidJavaClass billingClass = new AndroidJavaClass("com.gamedonia.inapppurchase.BillingPlugin"); billingClass.CallStatic("StopInAppBilling", new object [] {}); } catch (Exception ex) { Debug.Log(ex.Message); } }
public static void StartSession(string url) { #if UNITY_IPHONE && !UNITY_EDITOR aep_StartSession(url); #elif UNITY_ANDROID && !UNITY_EDITOR if (AndroidJNI.AttachCurrentThread() >= 0) { assurance.CallStatic("startSession", url); } #endif }
//Function to make sure the device is a Moverio BT-300. void CheckDeviceType() { Debug.Log(SystemInfo.deviceModel); if (SystemInfo.deviceModel.Equals("MS-7A59 (MSI)")) { AndroidJNI.AttachCurrentThread(); } else { MoverioDevice = false; } }
public override void AddBreadcrumbImpl(Breadcrumb breadcrumb) { AndroidJNI.AttachCurrentThread(); using var sentry = GetSentryJava(); using var javaBreadcrumb = new AndroidJavaObject("io.sentry.Breadcrumb"); javaBreadcrumb.Set("message", breadcrumb.Message); javaBreadcrumb.Set("type", breadcrumb.Type); javaBreadcrumb.Set("category", breadcrumb.Category); using var javaLevel = breadcrumb.Level.ToJavaSentryLevel(); javaBreadcrumb.Set("level", javaLevel); sentry.CallStatic("addBreadcrumb", javaBreadcrumb, null); }
public string Call(string commandName, params string[] args) { try { AndroidJNI.AttachCurrentThread(); return(_unityCallable.Call <string>(commandName, args)); } finally { AndroidJNI.DetachCurrentThread(); } }
private static AndroidJavaClass GetPluginClass() { if (_pluginClass == null && _pluginError == null) { AndroidJNI.AttachCurrentThread(); try { _pluginClass = new AndroidJavaClass("com.testcompany.testplugin.TestPlugin"); } catch (Exception e) { _pluginError = e; } } return(_pluginClass); }
private static void SendRawValue(string value) { Debug.Log("[APPSOCKET] Sent: " + value); if (Application.platform == RuntimePlatform.Android) { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass javaSocket = new AndroidJavaClass(AppProtocol.JAVA_CLASS)) { javaSocket.CallStatic(AppProtocol.JAVA_METHOD, value.ToString()); } } }
public OpenBackAndroid() { AndroidJNI.AttachCurrentThread(); using (AndroidJavaClass unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) using (AndroidJavaObject activity = unityClass.GetStatic <AndroidJavaObject>("currentActivity")) using (AndroidJavaObject context = activity.Call <AndroidJavaObject>("getApplicationContext")) { openBack = new AndroidJavaClass("com.openback.OpenBack"); openBack.CallStatic("initialize", context); } AndroidJNI.DetachCurrentThread(); }
//Function to make sure the device is a Moverio BT-300. void CheckDeviceType() { if (SystemInfo.deviceModel.Equals("EPSON EMBT3C") || SystemInfo.deviceModel.Equals("EPSON EMBT3S")) { AndroidJNI.AttachCurrentThread(); } else { #if UNITY_ANDROID && !UNITY_EDITOR MoverioDevice = false; #endif } }
private static void _GetRemoteNotifications() { AndroidJNI.AttachCurrentThread(); AndroidJavaClass notifClass = new AndroidJavaClass("com.gamedonia.pushnotifications.PushNotifications"); string[] notifications = notifClass.CallStatic <string[]>("getRemoteNotifications", new object [] {}); foreach (string notification in notifications) { AddNotification(notification); } }
/// <summary> /// Opens the rename dialog /// </summary> /// <param name="entry"></param> public async void Rename(AppEntry appTarget) { Debug.Assert(null != this.appToRename, "App to rename is null"); var filePath = appTarget.externalIconPath; bool cleanupFile = false; // If icon path is null, extract icon from apk if (null == filePath) { filePath = Path.Combine(AssetsDownloader.GetOrCreateDownloadPath(), this.appToRename.packageId + ".jpg"); cleanupFile = true; var bytes = appTarget.sprite.GetComponent <Image>().sprite.texture.EncodeToJPG(); using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true)) { await fileStream.WriteAsync(bytes, 0, bytes.Length); }; } await Task.Run(() => { AndroidJNI.AttachCurrentThread(); try { // Add to json file AddToRenameJsonFile(this.appToRename.packageId, appTarget.appName); // Add icon to zip using (AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) using (AndroidJavaObject currentActivity = unity.GetStatic <AndroidJavaObject>("currentActivity")) { var renameIconPackFilePath = Path.Combine(UnityEngine.Application.persistentDataPath, AppProcessor.RenameIconPackFileName); currentActivity.CallStatic("addFileToZip", renameIconPackFilePath, filePath, this.appToRename.packageId + ".jpg"); } } finally { AndroidJNI.DetachCurrentThread(); } }); if (cleanupFile && File.Exists(filePath)) { File.Delete(filePath); } // Reload the scene await SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name); }