From c1cb2d8c6034a2ee7aa8a5710bba15b14f76cebc Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期五, 18 八月 2023 18:54:31 +0800 Subject: [PATCH] 2023年08月18日18:54:22 --- HDL-ON_Android/SplashActivity.cs | 66 ++++++++++++++++++++++++++------- 1 files changed, 52 insertions(+), 14 deletions(-) diff --git a/HDL-ON_Android/SplashActivity.cs b/HDL-ON_Android/SplashActivity.cs index bd141ee..4fccb42 100644 --- a/HDL-ON_Android/SplashActivity.cs +++ b/HDL-ON_Android/SplashActivity.cs @@ -3,6 +3,7 @@ using Android.App; using Android.Content; using Android.Content.PM; +using Android.Locations; using Android.Net; using Android.OS; using Android.Support.V4.App; @@ -49,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; @@ -180,7 +189,7 @@ } }; - BaseActivity.OnCreateActoin += (activity, application) => + BaseActivity.OnCreateActoin = (activity, application) => { Language.CurrentLanguage = "Chinese"; Locale locale1 = Locale.Default; @@ -229,7 +238,7 @@ HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground); }; }; - BaseActivity.RefreshUIAction += (activity) => + BaseActivity.RefreshUIAction = (activity) => { Language.CurrentLanguage = "Chinese"; Locale locale1 = Locale.Default; @@ -258,11 +267,11 @@ MainPage.Show(); checkSomeInfo(); }; - BaseActivity.OnResumeAction += (activity) => + BaseActivity.OnResumeAction = (activity) => { checkSomeInfo(); }; - BaseActivity.OnDestroyAction += (activity) => + BaseActivity.OnDestroyAction = (activity) => { Console.WriteLine("OnDestroyAction"); //BusSocket.Stop(); @@ -275,20 +284,20 @@ //Shared.Application.IsGpsEnable = true; //bool isfirst = true; - + + var isfirst = true; //鑾峰彇缁忕含搴� Shared.Application.LocationAction = (lon, lat) => { try { - //if (isfirst) - //{ - // //鍙Е鍙戜竴娆� - // //Shared.Application.LocationAction = null; - // new HDL_ON.DAL.Server.HttpServerRequest().GetCityWeatherInfo(lon.ToString().Replace(",", "."), lat.ToString().Replace(",", ".")); - //} - //isfirst = false; + if (isfirst) + { + //鍙Е鍙戜竴娆� + new HDL_ON.DAL.Server.HttpServerRequest().GetCityWeatherInfo(lon.ToString().Replace(",", "."), lat.ToString().Replace(",", ".")); + } + isfirst = false; ///鐩戝惉缁忕含搴� HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.Current.AppLatAndLonEvent(lon, lat); //鍏抽棴瀹氫綅鏈嶅姟 @@ -410,7 +419,36 @@ } + + + + // 鍦ㄤ綘鐨勬椿鍔紙Activity锛夋垨鐗囨锛團ragment锛変腑鐨勬煇涓柟娉曚腑锛屽紑濮嬬洃鍚綅缃彉鍖� + void StartLocationUpdates() + { + // 鍒涘缓浣嶇疆绠$悊鍣� + var locationManager = (LocationManager)GetSystemService(Context.LocationService); + + // 璁剧疆浣嶇疆鐩戝惉鍣� + var locationListener = new MyLocationListener_V2(); + + // 璇锋眰浣嶇疆鏇存柊 + locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, locationListener); + } + + // 鍦ㄤ綘鐨勬椿鍔紙Activity锛夋垨鐗囨锛團ragment锛変腑鐨勬煇涓柟娉曚腑锛屽仠姝㈢洃鍚綅缃彉鍖� + void StopLocationUpdates() + { + // 鍒涘缓浣嶇疆绠$悊鍣� + var locationManager = (LocationManager)GetSystemService(Context.LocationService); + + // 璁剧疆浣嶇疆鐩戝惉鍣� + var locationListener = new MyLocationListener_V2(); + + // 鍋滄浣嶇疆鏇存柊 + locationManager.RemoveUpdates(locationListener); + } + + + } - - } \ No newline at end of file -- Gitblit v1.8.0