static IntPtr GetJavaMethodID(IntPtr classId, string name, string sig)
            {
                AndroidJNI.ExceptionClear();
                var mid = AndroidJNI.GetMethodID(classId, name, sig);

                IntPtr ex = AndroidJNI.ExceptionOccurred();
                if (ex != (IntPtr)0)
                {
                    AndroidJNI.ExceptionDescribe();
                    AndroidJNI.ExceptionClear();
                    return (IntPtr)0;
                }
                else
                {
                    return mid;
                }
            }
 public double GetHighPrecisionSkinTempLevel()
 {
     double currentTempLevel = -1.0;
     try
     {
         currentTempLevel = AndroidJNI.CallDoubleMethod(s_GameSDKRawObjectID, s_GetHighPrecisionSkinTempLevelID, s_NoArgs);
         if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
         {
             AndroidJNI.ExceptionDescribe();
             AndroidJNI.ExceptionClear();
         }
     }
     catch (Exception)
     {
         GameSDKLog.Debug("[Exception] GameSDK.getHighPrecisionSkinTempLevel() failed!");
     }
     return currentTempLevel;
 }
 public int GetSkinTempLevel()
 {
     int currentTempLevel = -1;
     try
     {
         currentTempLevel = AndroidJNI.CallIntMethod(s_GameSDKRawObjectID, s_GetSkinTempLevelID, s_NoArgs);
         if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
         {
             AndroidJNI.ExceptionDescribe();
             AndroidJNI.ExceptionClear();
         }
     }
     catch (Exception)
     {
         GameSDKLog.Debug("[Exception] GameSDK.getSkinTempLevel() failed!");
     }
     return currentTempLevel;
 }
            public double GetGpuFrameTime()
            {
                double gpuFrameTime = -1.0;
                try
                {
                    gpuFrameTime = AndroidJNI.CallDoubleMethod(s_GameSDKRawObjectID, s_GetGpuFrameTimeID, s_NoArgs);
                    if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
                    {
                        AndroidJNI.ExceptionDescribe();
                        AndroidJNI.ExceptionClear();
                    }
                }
                catch (Exception)
                {
                    GameSDKLog.Debug("[Exception] GameSDK.getGpuFrameTime() failed!");
                }

                return gpuFrameTime;
            }
    public static void FetchOBB()
    {
        using (AndroidJavaClass unity_player = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            AndroidJavaObject current_activity = unity_player.GetStatic <AndroidJavaObject>("currentActivity");

            AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent",
                                                             current_activity,
                                                             new AndroidJavaClass("com.unity3d.plugin.downloader.UnityDownloaderActivity"));

            int Intent_FLAG_ACTIVITY_NO_ANIMATION = 0x10000;
            intent.Call <AndroidJavaObject>("addFlags", Intent_FLAG_ACTIVITY_NO_ANIMATION);
            intent.Call <AndroidJavaObject>("putExtra", "unityplayer.Activity",
                                            current_activity.Call <AndroidJavaObject>("getClass").Call <string>("getName"));
            current_activity.Call("startActivity", intent);

            if (AndroidJNI.ExceptionOccurred() != System.IntPtr.Zero)
            {
                Debug.LogError("Exception occurred while attempting to start DownloaderActivity - is the AndroidManifest.xml incorrect?");
                AndroidJNI.ExceptionDescribe();
                AndroidJNI.ExceptionClear();
            }
        }
    }
 public static void FetchOBB()
 {
     using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
     {
         AndroidJavaObject @static           = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity");
         AndroidJavaObject androidJavaObject = new AndroidJavaObject("android.content.Intent", @static, new AndroidJavaClass("com.unity3d.plugin.downloader.UnityDownloaderActivity"));
         int num = 65536;
         androidJavaObject.Call <AndroidJavaObject>("addFlags", new object[1] {
             num
         });
         androidJavaObject.Call <AndroidJavaObject>("putExtra", new object[2]
         {
             "unityplayer.Activity",
             @static.Call <AndroidJavaObject>("getClass", new object[0]).Call <string>("getName", new object[0])
         });
         @static.Call("startActivity", androidJavaObject);
         if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
         {
             Debug.LogError("Exception occurred while attempting to start DownloaderActivity - is the AndroidManifest.xml incorrect?");
             AndroidJNI.ExceptionDescribe();
             AndroidJNI.ExceptionClear();
         }
     }
 }
Exemple #7
0
    public static void init()
    {
        if (Application.get_platform() != 11)
        {
            return;
        }
        try
        {
            using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.upsight.android.unity.UpsightPlugin"))
            {
                if (((AndroidJavaObject)androidJavaClass).CallStatic <bool>("isEnabled", new object[0]) == null)
                {
                    Debug.LogWarning((object)"Upsight.init() was called but the SDK is currently disabled from the Upsight SDK Management Extension. Upsight will not initialize.");
                    return;
                }
            }
        }
        catch
        {
            Debug.LogError((object)"Error while checking if the Upsight SDK is enabled. Unable to initialize");
            return;
        }
        if (Upsight.Initialized)
        {
            return;
        }
        Upsight.Initialized = true;
        UpsightManager.init();
        try
        {
            Upsight._pluginBase = new AndroidJavaObject("com.upsight.android.unity.UpsightPlugin", new object[0]);
            if (Upsight._pluginBase != null)
            {
                if (!(AndroidJNI.ExceptionOccurred() != IntPtr.Zero))
                {
                    goto label_15;
                }
            }
            Debug.LogError((object)"Upsight initialization failed! JNI Exception thrown:");
            AndroidJNI.ExceptionDescribe();
            Upsight._pluginBase = (AndroidJavaObject)null;
            AndroidJNI.ExceptionClear();
            return;
        }
        catch (Exception ex)
        {
            Debug.LogError((object)"Upsight initialization failed!");
            Debug.LogException(ex);
            Upsight._pluginBase = (AndroidJavaObject)null;
            return;
        }
label_15:
        try
        {
            Upsight._pluginMarketingExtension = new AndroidJavaObject("com.upsight.android.unity.UpsightMarketingManager", new object[0]);
            if (Upsight._pluginMarketingExtension != null)
            {
                Upsight._pluginBase.Call("registerExtension", new object[1]
                {
                    (object)Upsight._pluginMarketingExtension
                });
            }
        }
        catch
        {
            Debug.LogWarning((object)"Upsight Marketing Extension not included.");
            Upsight._pluginMarketingExtension = (AndroidJavaObject)null;
        }
        try
        {
            Upsight._pluginPushExtension = new AndroidJavaObject("com.upsight.android.unity.UpsightPushManager", new object[0]);
            if (Upsight._pluginPushExtension == null)
            {
                return;
            }
            Upsight._pluginBase.Call("registerExtension", new object[1]
            {
                (object)Upsight._pluginPushExtension
            });
        }
        catch
        {
            Debug.LogWarning((object)"Upsight Push Extension not included.");
            Upsight._pluginPushExtension = (AndroidJavaObject)null;
        }
    }