From de255fa314823290a833c10d30424e42e91f56f0 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 13 七月 2023 16:30:36 +0800 Subject: [PATCH] 安卓后台进入前台问题 --- HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs | 10 ++++++++-- HDL-ON_Android/Properties/AndroidManifest.xml | 2 +- HDL-ON_Android/SplashActivity.cs | 20 ++++++++++++-------- HDL_ON/DAL/DriverLayer/UdpSocket.cs | 4 ++-- HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs | 2 +- HDL-ON_Android/Other/HDLONUtils.cs | 12 ++++++------ HDL-ON_iOS/AppDelegate.cs | 1 - HDL-ON_Android/Application.cs | 6 +----- 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/HDL-ON_Android/Application.cs b/HDL-ON_Android/Application.cs index d76c42e..105a0fe 100644 --- a/HDL-ON_Android/Application.cs +++ b/HDL-ON_Android/Application.cs @@ -125,7 +125,6 @@ multicast.Release(); //杩涘叆鍚庡彴 UserInfo.Current.unlockTime = DateTime.Now; - } } @@ -153,7 +152,7 @@ /// </summary> void BusSocketStop() { - //IsEnterBackground = true; + CloseTime = DateTime.Now; MainPage.IsEnterBackground = true; //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵�� @@ -167,15 +166,12 @@ /// </summary> void BusSocketStart() { - //IsEnterBackground = false; - if (CloseTime.AddSeconds(10) < DateTime.Now) { //鍚庡彴瓒呰繃10s灏辨柇寮�MQTT閲嶈繛 //if (HDL_ON.DriverLayer.Control.Ins.IsRemote) { HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false); - HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Local = false; } } diff --git a/HDL-ON_Android/Other/HDLONUtils.cs b/HDL-ON_Android/Other/HDLONUtils.cs index 5f184b9..570b56c 100644 --- a/HDL-ON_Android/Other/HDLONUtils.cs +++ b/HDL-ON_Android/Other/HDLONUtils.cs @@ -32,12 +32,12 @@ } } - public static void StartSplashActivity() - { - Intent intent = new Intent(Shared.Application.Activity, typeof(SplashActivity)); - Shared.Application.Activity.StartActivity(intent); - Shared.Application.Activity.Finish(); - } + //public static void StartSplashActivity() + //{ + // Intent intent = new Intent(Shared.Application.Activity, typeof(SplashActivity)); + // Shared.Application.Activity.StartActivity(intent); + // Shared.Application.Activity.Finish(); + //} } } diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml index ff63ea2..1cab751 100644 --- a/HDL-ON_Android/Properties/AndroidManifest.xml +++ b/HDL-ON_Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@ 锘�<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.8.1" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202307121"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.8.1" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202307131"> <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <!--鍙嬬洘--> diff --git a/HDL-ON_Android/SplashActivity.cs b/HDL-ON_Android/SplashActivity.cs index afcffdf..4fccb42 100644 --- a/HDL-ON_Android/SplashActivity.cs +++ b/HDL-ON_Android/SplashActivity.cs @@ -24,10 +24,6 @@ [IntentFilter(new string[] { "com.hdl.onpro.SplashActivity", Intent.ActionView })] public class SplashActivity : Activity { - - - - protected override void OnActivityResult(int requestCode, Result resultVal, Intent data) { if (requestCode == 99) @@ -54,12 +50,20 @@ { base.OnCreate(savedInstanceState); + if(Shared.Application.Activity != null && Shared.Application.Activity.GetType() == typeof(BaseActivity)) + { + Finish(); + return; + } + //Intent i = new Intent(this, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class); //StartActivityForResult(i, 1); //OverridePendingTransition(0, 0); //initAll(); if (HDL_ON.OnAppConfig.Instance.FirstRunApp || !HDL_ON.OnAppConfig.Instance.isAgreePrivacyPolicy) { + //OnAppConfig.Instance.FirstRunApp = false; + //OnAppConfig.Instance.SaveConfig(); Language.CurrentLanguage = "Chinese"; Locale locale1 = Locale.Default; var localeList = Resources.Configuration.Locale; @@ -185,7 +189,7 @@ } }; - BaseActivity.OnCreateActoin += (activity, application) => + BaseActivity.OnCreateActoin = (activity, application) => { Language.CurrentLanguage = "Chinese"; Locale locale1 = Locale.Default; @@ -234,7 +238,7 @@ HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground); }; }; - BaseActivity.RefreshUIAction += (activity) => + BaseActivity.RefreshUIAction = (activity) => { Language.CurrentLanguage = "Chinese"; Locale locale1 = Locale.Default; @@ -263,11 +267,11 @@ MainPage.Show(); checkSomeInfo(); }; - BaseActivity.OnResumeAction += (activity) => + BaseActivity.OnResumeAction = (activity) => { checkSomeInfo(); }; - BaseActivity.OnDestroyAction += (activity) => + BaseActivity.OnDestroyAction = (activity) => { Console.WriteLine("OnDestroyAction"); //BusSocket.Stop(); diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs index 701edba..4c89487 100644 --- a/HDL-ON_iOS/AppDelegate.cs +++ b/HDL-ON_iOS/AppDelegate.cs @@ -484,7 +484,6 @@ //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵�� HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false; HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop(); - HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Local = false; } diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs index f454bf1..6d64a06 100644 --- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs +++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs @@ -77,7 +77,8 @@ } catch { } busSocket = null; - MainPage.Log("Socket鍏抽棴"); + HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Local = false; + MainPage.Log("Socket鍏抽棴"); } /// <summary> @@ -140,7 +141,6 @@ //mqtt杩炴帴鏁版嵁璇诲彇 A鍗忚缃戠粶璁惧淇℃伅璇诲彇鍥炲 澶勭悊 if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585) { - MainPage.Log($"灞�鍩熺綉udp淇℃伅"); Control.Ins.ConvertReceiveData(bytes, ((IPEndPoint)packet.RemoteEndPoint).Address.ToString()); } else if (((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹� diff --git a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs index 8badede..658de74 100644 --- a/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs +++ b/HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs @@ -338,7 +338,7 @@ #region 鈻� -- 鏂版帴鍚拰寮�閿佹帴鍙______________________________ /// <summary> - /// 寮�閿� + /// 鍙瀵硅寮�閿� /// </summary> public void HDLUnlockAction() { diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs index 564dd00..fbadb7f 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs @@ -269,9 +269,15 @@ { Application.RunOnMainThread(() => { - if (bodyView != null) + try { - bodyView.CheckLinkStatus(); + if (bodyView != null) + { + bodyView.CheckLinkStatus(); + } + }catch(Exception ex) + { + MainPage.Log($"LoadEvent_CheckLinkStatus : {ex.Message}"); } }); } -- Gitblit v1.8.0