Ejemplo n.º 1
0
        /************************************************Unity方法与事件***********************************************/
        protected override void Start()
        {
#if (UNITY_ANDROID) && (!UNITY_EDITOR)
            int batteryCapacity = BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext());
            this.inCharging = BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext());
#else
            int batteryCapacity = 15;
#endif
            this.InvokeRepeating("UpdateBatteryLevel", 0, 5);
            this.OnBatteryLevelChange(batteryCapacity);
            BatteryUtils.registerPowerConnectionListener(this.OnConnected, this.OnDisconnected);
            BatteryUtils.registerBatteryLevelListener(null, null, this.OnBatteryLevelChange);
            GuLog.Debug(string.Format("----BattaryStatusListenerView.Start----unSafe: {0}", true));
        }
Ejemplo n.º 2
0
        private void BatteryInitial()
        {
            BatteryUtils.registerBatteryLevelListener(onBatteryLow, onBatteryOkay, onBatteryLevelChange);

            BatteryUtils.registerPowerConnectionListener(onConnected, onDisconnected);

            if (BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext()))
            {
                RepeatBatteryUppdate();
            }
            else
            {
                onDisconnected();
            }
            bool batteryStatus = BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext());

            GuLog.Info("<><InCharging>BatteryUtils.isCharging<><>" + batteryStatus.ToString());
        }