黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/GateWay.Droid/Application.cs
@@ -20,7 +20,6 @@
namespace com.hdl.home
{
    [Activity(Name = "com.hdl.home.wxapi.WXEntryActivity", Exported = true, Theme = "@android:style/Theme.Translucent", LaunchMode = Android.Content.PM.LaunchMode.SingleTask)]
    class WXEntryActivity : Android.App.Activity, IWXAPIEventHandler
    {
@@ -83,6 +82,12 @@
    public class Application : Android.App.Application
    {
        public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { }
        /// <summary>
        /// 检测内存泄露的东西
        /// </summary>
        ///private Square.LeakCanary.RefWatcher _refWatcher;
        public override void OnCreate()
        {
            //如果不是App的主进程,则不需要处理
@@ -99,11 +104,18 @@
            catch (Exception ex)
            {
                //调试:记录系统异常
                Shared.Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.SystemLogFile, ex.Message + "\r\n" + ex.StackTrace, true, false);
                Shared.Phone.HdlLogLogic.Current.WriteOtherText(Shared.Phone.HdlFileNameResourse.LogDirectory, ex.Message + "\r\n" + ex.StackTrace, true, false);
            }
            base.OnCreate();
            // 通过WXAPIFactory工厂,获取IWXAPI的实例
            //api = WXAPIFactory.CreateWXAPI(this, "wx2ec8f53f6fa36e82", true);
            base.OnCreate();
            // 通过WXAPIFactory工厂,获取IWXAPI的实例
            //api = WXAPIFactory.CreateWXAPI(this, "wx2ec8f53f6fa36e82", true);
            //检测内存泄露的东西
            //if (Square.LeakCanary.LeakCanaryXamarin.IsInAnalyzerProcess(this) == false)
            //{
            //    _refWatcher = Square.LeakCanary.LeakCanaryXamarin.Install(this);
            //    _refWatcher.Watch(this);
            //}
            // 将应用的appId注册到微信
            api?.RegisterApp("wx2ec8f53f6fa36e82");
@@ -136,12 +148,14 @@
            var req = new SendAuth.Req { Scope = "snsapi_userinfo", State = "ZigbeeApp" };
            api?.SendReq(req);
        }
        /// <summary>
      /// 所有初始化全部在这个方法实现
      /// </summary>
      void initAll()
        {
            Shared.Application.IsGpsEnable = System.IO.File.Exists(Shared.Phone.UserCenter.DirNameResourse.OpenGbsFile);
            //取消屏幕常亮
            BaseActivity.KeepScreenON = false;
            //隐藏底部软按键
            BaseActivity.IsHideVirualButtons = true;
@@ -161,7 +175,7 @@
            {
                try
                {
                    if (Shared.Common.CommonPage.BackKeyCanClick == false)
                    if (Shared.Common.Config.Instance.BackKeyCanClick == false)
                    {
                        //不允许按返回键
                        return;
@@ -211,17 +225,21 @@
            {
                Shared.Application.FontSize = 12;
                AppCenter.Start("4802834a-e7e9-4dd8-93f1-c2f88f0bd464", typeof(Analytics), typeof(Crashes));
#if Release
            //保存获取的极光服务器上的注册ID到本地文件
            var registrationId = JPushInterface.GetRegistrationID(activity);
#if DEBUG
                //测试ID,瞎写的
                Shared.Common.Config.Instance.RegistrationID = "93f1c2f88f0bd464";
#endif
#if Release
                //保存获取的极光服务器上的注册ID到本地文件
                var registrationId = JPushInterface.GetRegistrationID(activity);
                System.Console.WriteLine("registrationId-极光id=" + registrationId);
                if (!string.IsNullOrEmpty(registrationId))
            {
            Shared.Common.Config.Instance.RegistrationID = registrationId;
            Shared.Common.Config.Instance.Save();
            }
            //调试:记录极光ID
            Shared.Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "receive1:" + registrationId, true, true);
                if (!string.IsNullOrEmpty(registrationId))
                {
                    Shared.Common.Config.Instance.RegistrationID = registrationId;
                    Shared.Common.Config.Instance.Save();
                }
                //调试:记录极光ID
                Shared.Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "receive1:" + registrationId, true, true);
#endif
            };
            BaseActivity.RefreshUIAction += (activity) =>
@@ -361,7 +379,6 @@
                    if (!string.IsNullOrEmpty(regId))
                    {
                        Shared.Common.Config.Instance.RegistrationID = regId;
                        Shared.Common.Config.Instance.Save();
                    }
#if Release
                    //调试:记录极光ID
@@ -410,7 +427,7 @@
            System.Console.WriteLine(TAG, "extras : " + extras);
            //处理极光消息推送的逻辑函数
            Shared.Phone.UserCenter.HdlJiguangMsgPushLogic.Current.AdjustJiguangMsgPush(title, message, extras);
            Shared.Phone.HdlJiguangMsgPushLogic.Current.AdjustJiguangMsgPush(title, message, extras);
        }
        /// <summary>
        /// 打开消息显示界面