/** OpenFileDialog
         */
        public static void OpenFileDialog(Root_MonoBehaviour a_root_monobehaviour, string a_title, string a_extension)
        {
            a_root_monobehaviour.openfiledialog_result = null;

            UnityEngine.AndroidJavaClass t_class_openfiledialog = new UnityEngine.AndroidJavaClass("fee.platform.Android_OpenFileDialogActivity");
            t_class_openfiledialog.CallStatic("Open", a_title, a_extension);
        }
示例#2
0
 /// <summary>
 /// 设置接收华为推送设置结果的game object
 /// </summary>
 /// <param name="objName">game object 名称</param>
 public static void SetHuaweiPushReceiverObject(string objName)
 {
     UnityEngine.AndroidJavaClass clsSystemUtil = new UnityEngine.AndroidJavaClass("com.netease.hwpushwrapper.HWPush");
     if (clsSystemUtil != null)
     {
         clsSystemUtil.CallStatic("setReceiverObject", objName);
     }
 }
示例#3
0
        //同步加载Android asset文件夹中文件字节
        public static byte[] UF_LoadAndroidAssetFile(string filepath)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            UnityEngine.AndroidJavaClass m_AndroidJavaClass = new UnityEngine.AndroidJavaClass("com.unity.toolkit.StreamFileLoad");
            var bytes = m_AndroidJavaClass.CallStatic <byte[]>("load", filepath);
            return(bytes == null || bytes.Length == 0 ? null : bytes);
#else
            return(null);
#endif
        }
        public static string GetAndroidExternalFilesDir()
        {
            using (UnityEngine.AndroidJavaClass unityPlayer = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                using (UnityEngine.AndroidJavaObject context = unityPlayer.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"))
                {
                    // Get all available external file directories (emulated and sdCards)
                    UnityEngine.AndroidJavaObject[] externalFilesDirectories = context.Call <UnityEngine.AndroidJavaObject[]>("getExternalFilesDirs", (object)null);
                    UnityEngine.AndroidJavaObject   emulated = null;
                    UnityEngine.AndroidJavaObject   sdCard   = null;

                    for (int i = 0; i < externalFilesDirectories.Length; i++)
                    {
                        UnityEngine.AndroidJavaObject directory = externalFilesDirectories[i];
                        using (UnityEngine.AndroidJavaClass environment = new UnityEngine.AndroidJavaClass("android.os.Environment"))
                        {
                            // Check which one is the emulated and which the sdCard.
                            bool isRemovable = environment.CallStatic <bool>("isExternalStorageRemovable", directory);
                            bool isEmulated  = environment.CallStatic <bool>("isExternalStorageEmulated", directory);
                            if (isEmulated)
                            {
                                emulated = directory;
                            }
                            else if (isRemovable && isEmulated == false)
                            {
                                sdCard = directory;
                            }
                        }
                    }
                    // Return the sdCard if available
                    if (sdCard != null)
                    {
                        return(sdCard.Call <string>("getAbsolutePath"));
                    }
                    else
                    {
                        return(emulated.Call <string>("getAbsolutePath"));
                    }
                }
            }
        }
示例#5
0
 /** キャンセル。
  */
 public static void Cancel(Root_MonoBehaviour a_root_monobehaviour)
 {
     if (a_root_monobehaviour.loadandroidcontentfile != null)
     {
         try{
             using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){
                 t_class_loadcontentfile.CallStatic("Cancel", a_root_monobehaviour.loadandroidcontentfile);
             }
         }catch (System.Exception t_exception) {
             Tool.DebugReThrow(t_exception);
         }
     }
 }
示例#6
0
        public string FindDeviceCultureName()
        {
            string result = System.Globalization.CultureInfo.CurrentCulture.Name;

#if UNITY_EDITOR
#elif UNITY_ANDROID
            using (UnityEngine.AndroidJavaClass cls = new UnityEngine.AndroidJavaClass("java.util.Locale")) {
                using (UnityEngine.AndroidJavaObject locale = cls.CallStatic <UnityEngine.AndroidJavaObject>("getDefault")) {
                    result = locale.Call <string>("getLanguage") + "-" + locale.Call <string>("getCountry");
                }
            }
#elif UNITY_IOS
#else
#endif
            return(result);
        }
示例#7
0
        /** GetThreadStatus。
         */
        public static int GetThreadStatus(Root_MonoBehaviour a_root_monobehaviour)
        {
            int t_ret = -1;

            if (a_root_monobehaviour.loadandroidcontentfile != null)
            {
                try{
                    using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){
                        t_ret = t_class_loadcontentfile.CallStatic <int>("GetThreadStatus", a_root_monobehaviour.loadandroidcontentfile);
                    }
                }catch (System.Exception t_exception) {
                    Tool.DebugReThrow(t_exception);
                }
            }

            return(t_ret);
        }
示例#8
0
        /** IsComplate。
         */
        public static bool IsComplate(Root_MonoBehaviour a_root_monobehaviour)
        {
            bool t_ret = false;

            if (a_root_monobehaviour.loadandroidcontentfile != null)
            {
                try{
                    using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){
                        t_ret = t_class_loadcontentfile.CallStatic <bool>("IsComplate", a_root_monobehaviour.loadandroidcontentfile);
                    }
                }catch (System.Exception t_exception) {
                    Tool.DebugReThrow(t_exception);
                    t_ret = false;
                }
            }

            return(t_ret);
        }
示例#9
0
 /// <summary>
 /// 连接华为推送并获取token,必须集成华为推送SDK
 /// </summary>
 public static void InitHuaweiPush()
 {
     using (var actClass = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"))
     {
         UnityEngine.AndroidJavaObject curActivityContext = actClass.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
         if (curActivityContext != null)
         {
             UnityEngine.AndroidJavaClass clsSystemUtil = new UnityEngine.AndroidJavaClass("com.netease.hwpushwrapper.HWPush");
             if (clsSystemUtil != null)
             {
                 clsSystemUtil.CallStatic("initHuaweiPush", curActivityContext);
                 UnityEngine.Debug.Log("call java method initHuaweiPush");
             }
             else
             {
                 UnityEngine.Debug.Log("can't find class com.netease.hwpushwrapper.HWPush");
             }
         }
     }
 }
示例#10
0
        private static void InitSystemUtil()
        {
#if UNITY_ANDROID
            try
            {
                /* The Mono garbage collector should release all created instances of AndroidJavaObject and AndroidJavaClass after use,
                 * but it is advisable to keep them in a using(){} statement to ensure they are deleted as soon as possible.
                 * Without this, you cannot be sure when they will be destroyed.
                 */
                using (var actClass = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                {
                    UnityEngine.AndroidJavaObject curActivityContext = actClass.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
                    if (curActivityContext != null)
                    {
                        UnityEngine.AndroidJavaClass clsSystemUtil = new UnityEngine.AndroidJavaClass("com.netease.nimlib.NIMSDK");
                        if (clsSystemUtil != null)
                        {
                            NimUtility.Log.Info("com.netease.nimlib.NIMSDK found");
                            Boolean init = clsSystemUtil.CallStatic <Boolean>("init", curActivityContext, "fjni_wrapper");
                            NimUtility.Log.Info("init:" + init);
                            //string androidId = clsSystemUtil.CallStatic<String>("getAndroidId");
                            //NimUtility.Log.Info("androidId:" + androidId);
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                System.Console.Write("initAndroidExceptionHandler failed, an unexpected error: " + e.ToString());
            }
#endif

#if UNITY_IPHONE || UNITY_IOS
            if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.IPhonePlayer)
            {
                //TODO:
            }
#endif
        }
示例#11
0
        /** 開始。
         */
        public static bool Start(Root_MonoBehaviour a_root_monobehaviour, Fee.File.Path a_path)
        {
            if (a_root_monobehaviour.loadandroidcontentfile == null)
            {
                UnityEngine.AndroidJavaObject t_async_object = null;

                try{
                    using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){
                        t_async_object = t_class_loadcontentfile.CallStatic <UnityEngine.AndroidJavaObject>("Start", a_path.GetPath());
                    }
                }catch (System.Exception t_exception) {
                    Tool.DebugReThrow(t_exception);
                }

                if (t_async_object != null)
                {
                    a_root_monobehaviour.loadandroidcontentfile = t_async_object;
                    return(true);
                }
            }

            return(false);
        }
示例#12
0
        /** GetResult。
         */
        public static byte[] GetResult(Root_MonoBehaviour a_root_monobehaviour)
        {
            byte[] t_ret = null;

            if (a_root_monobehaviour.loadandroidcontentfile != null)
            {
                try{
                    using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){
                        using (UnityEngine.AndroidJavaObject t_array_object = t_class_loadcontentfile.CallStatic <UnityEngine.AndroidJavaObject>("GetResult", a_root_monobehaviour.loadandroidcontentfile)){
                            if (t_array_object != null)
                            {
                                System.IntPtr t_array_object_pointer = t_array_object.GetRawObject();
                                t_ret = UnityEngine.AndroidJNIHelper.ConvertFromJNIArray <byte[]>(t_array_object_pointer);
                            }
                        }
                    }
                }catch (System.Exception t_exception) {
                    Tool.DebugReThrow(t_exception);
                    t_ret = null;
                }
            }

            return(t_ret);
        }
示例#13
0
 // ()I
 public static int staticMethod()
 {
     return(_javaClass.CallStatic <int>("staticMethod", new object[] {}));
 }