wxr
2021-07-01 43b0d5870d528f23ecd6aeceb6cfd4325188b46f
HDL-ON_Android/Application.cs
@@ -1,13 +1,19 @@
using System;
using System.Net;
using System.Threading.Tasks;
using Android;
using Android.App;
using Android.Content;
using Android.Net;
using Android.OS;
using Android.Runtime;
using Android.Widget;
using CN.Jpush.Android.Api;
using HDL_ON;
using Java.Util;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using Shared;
namespace HDL_ON_Android
@@ -29,6 +35,8 @@
        public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { }
        public override void OnCreate()
        {
            //注册未处理异常事件
            AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
            if (Shared.Application.Activity != null)
            {
                reStartApp(this);
@@ -41,6 +49,9 @@
            initAll();
        }
        /// <summary>
        /// 所有初始化全部在这个方法实现
        /// </summary>
@@ -51,8 +62,34 @@
            Manifest.Permission.Camera, Manifest.Permission.ProcessOutgoingCalls, Manifest.Permission.GetAccounts};
            //禁止屏幕长亮
            BaseActivity.KeepScreenON = false;
            //隐藏迪拜虚拟按键
            //隐藏虚拟按键
            BaseActivity.IsHideVirualButtons = true;
            //实现安卓返回按键
            BaseActivity.BackKeyAction = () =>
            {
                try
                {
                    var result = MainPage.LoadEvent_BackAction();
                    switch (result)
                    {
                        case 0:
                            break;
                        case 1:
                        case 2:
                            BaseActivity.VerifyDateTime = DateTime.MaxValue;
                            break;
                        default:
                            BaseActivity.VerifyDateTime = DateTime.MaxValue;
                            break;
                    }
                }
                catch (Exception ex)
                {
                    MainPage.Log(ex.Message);
                    BaseActivity.VerifyDateTime = DateTime.MaxValue;
                }
            };
            init();
            BaseActivity.OnCreateActoin += (activity, application) =>
            {
@@ -63,7 +100,10 @@
                {
                    Language.CurrentLanguage = "Chinese";
                }
                else
                {
                    Language.CurrentLanguage = "English";
                }
                //获取极光推送ID
                GetJPushRegistrationID(activity);
@@ -99,7 +139,8 @@
            BaseActivity.OnResumeAction += (activity) =>
            {
                checkSomeInfo();
            };
            BaseActivity.OnDestroyAction += (activity) =>
            {
@@ -108,7 +149,7 @@
                //UserInfo.Current.unlockTime = DateTime.Now;
            };
            HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
@@ -123,14 +164,14 @@
                    //关闭定位服务
                    Shared.Application.StopGPSLocationService();
                }
                  catch(Exception ex)
                catch (Exception ex)
                {
                    Utlis.WriteLine("GetCityInfo catch"+ ex.Message);
                    Utlis.WriteLine("GetCityInfo catch" + ex.Message);
                }
                MainPage.Log($"经纬度:::{lon}:{lat}");
            };
        }
        /// <summary>
@@ -139,8 +180,10 @@
        /// <param name="activity"></param>
        void GetJPushRegistrationID(BaseActivity activity)
        {
            try
            {
                //保存获取的极光服务器上的注册ID到本地文件
                var tokenID = JPushInterface.GetRegistrationID(activity);
                Console.WriteLine("RegistrationID:  " + tokenID);
@@ -185,9 +228,9 @@
        {
            //手机名称 Android.OS.Build.Manufacturer;
            //OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
#if DEBUG
            CN.Jpush.Android.Api.JPushInterface.SetDebugMode(true);
#endif
//#if DEBUG
            //CN.Jpush.Android.Api.JPushInterface.SetDebugMode(true);
//#endif
            CN.Jpush.Android.Api.JPushInterface.Init(this);
        }
@@ -330,7 +373,7 @@
            //进入后台mqtt正在连接重置状态
            HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
            HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
        }
        /// <summary>
@@ -343,7 +386,7 @@
            if (CloseTime.AddSeconds(10) < DateTime.Now)
            {
                //后台超过10s就断开MQTT重连
                if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
                //if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
                {
                    HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false);
                }
@@ -354,8 +397,11 @@
            HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
    }
}
}