wjc
2023-07-26 9508510f0b27da3278fa1161eb2ba3dd1e3e2030
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;
@@ -126,7 +135,7 @@
            JPushInterface.Init(this);
            Com.Chteam.Agent.BuglyAgentHelper.Init(this.ApplicationContext, "316a8f5d83");
            BaseActivity.OnCreateActoin += (activity, application) =>
            {
@@ -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)或片段(Fragment)中的某个方法中,开始监听位置变化
        void StartLocationUpdates()
        {
            // 创建位置管理器
            var locationManager = (LocationManager)GetSystemService(Context.LocationService);
            // 设置位置监听器
            var locationListener = new MyLocationListener_V2();
            // 请求位置更新
            locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, locationListener);
        }
        // 在你的活动(Activity)或片段(Fragment)中的某个方法中,停止监听位置变化
        void StopLocationUpdates()
        {
            // 创建位置管理器
            var locationManager = (LocationManager)GetSystemService(Context.LocationService);
            // 设置位置监听器
            var locationListener = new MyLocationListener_V2();
            // 停止位置更新
            locationManager.RemoveUpdates(locationListener);
        }
    }
}