wxr
2023-12-29 19b4abbebede2255b8d9f286105c7bf41d254429
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;
@@ -12,19 +13,17 @@
using Com.Hdl.ON.Jpush.Androidjpush;
using HDL_ON;
using Java.Util;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using Shared;
namespace HDL_ON_Android
{
    [Activity(Theme = "@style/SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTask, Name = "com.hdl.onpro.SplashActivity", ScreenOrientation = ScreenOrientation.Portrait)]
    [IntentFilter(new string[] { "com.hdl.onpro.SplashActivity", Intent.ActionView })]
    [Activity(Theme = "@style/SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTask, Name = "com.jinlu.onpro.SplashActivity", ScreenOrientation = ScreenOrientation.Portrait)]
    [IntentFilter(new string[] { "com.hdl.jinlu.SplashActivity", Intent.ActionView })]
    public class SplashActivity : Activity
    {
        protected override void OnActivityResult(int requestCode, Result resultVal, Intent data)
        {
            Console.WriteLine("123456");
            if (requestCode == 99)
            {
                if (resultVal == Result.Ok)
@@ -49,14 +48,24 @@
        {
            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 DEBUG
            HDL_ON.OnAppConfig.Instance.isAgreePrivacyPolicy = true;
#endif
            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;
                Console.WriteLine("当前语言缩写:" + localeList.Language);
                if (localeList.Language == "zh")
@@ -75,6 +84,10 @@
                {
                    Language.CurrentLanguage = "български";
                }
                //else if (localeList.Language == "uk")
                //{
                //    Language.CurrentLanguage = "Ukraine";
                //}
                else
                {
                    Language.CurrentLanguage = "English";
@@ -117,15 +130,15 @@
        void initOhterSdk()
        {
            //注册未处理异常事件
            AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
            //AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
            //手机名称 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
            JPushInterface.Init(this);
            Com.Chteam.Agent.BuglyAgentHelper.Init(this.ApplicationContext, "316a8f5d83");
            //Com.Chteam.Agent.BuglyAgentHelper.Init(this.ApplicationContext, "316a8f5d83");
            
            BaseActivity.OnCreateActoin += (activity, application) =>
@@ -135,10 +148,17 @@
            };
            //初始化友盟sdk
            Com.Hdl.Umsdk.UmSdk.InitUmSdk(this, "61d565d9e0f9bb492bbc3d5a", "Android");
            //初始化友盟sdk config
            Com.Hdl.Umsdk.UmSdk.InitUMConfigure(this, "61d565d9e0f9bb492bbc3d5a", "Android", "");
            try
            {
                //初始化友盟sdk
                //Com.Hdl.Umsdk.UmSdk.InitUmSdk(this, "61d565d9e0f9bb492bbc3d5a", "Android");
                //////初始化友盟sdk config
                //Com.Hdl.Umsdk.UmSdk.InitUMConfigure(this, "61d565d9e0f9bb492bbc3d5a", "Android", "");
            }
            catch (Exception ex)
            {
                Console.WriteLine("初始化友盟SDK异常:" + ex.Message);
            }
        }
@@ -180,10 +200,9 @@
                }
            };
            BaseActivity.OnCreateActoin += (activity, application) =>
            BaseActivity.OnCreateActoin = (activity, application) =>
            {
                Language.CurrentLanguage = "Chinese";
                Locale locale1 = Locale.Default;
                var localeList = Resources.Configuration.Locale;
                Console.WriteLine("当前语言编号" + localeList.Language);
                if (localeList.Language == "zh")
@@ -202,6 +221,10 @@
                {
                    Language.CurrentLanguage = "български";
                }
                //else if (localeList.Language == "uk")
                //{
                //    Language.CurrentLanguage = "Ukraine";
                //}
                else
                {
                    Language.CurrentLanguage = "English";
@@ -229,10 +252,9 @@
                    HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
                };
            };
            BaseActivity.RefreshUIAction += (activity) =>
            BaseActivity.RefreshUIAction = (activity) =>
            {
                Language.CurrentLanguage = "Chinese";
                Locale locale1 = Locale.Default;
                var localeList = Resources.Configuration.Locale;
                Console.WriteLine("当前语言:" + localeList.Language);
                if (localeList.Language == "zh")
@@ -251,6 +273,10 @@
                {
                    Language.CurrentLanguage = "български";
                }
                //else if (localeList.Language == "uk")
                //{
                //    Language.CurrentLanguage = "Ukraine";
                //}
                else
                {
                    Language.CurrentLanguage = "English";
@@ -258,11 +284,11 @@
                MainPage.Show();
                checkSomeInfo();
            };
            BaseActivity.OnResumeAction += (activity) =>
            BaseActivity.OnResumeAction = (activity) =>
            {
                checkSomeInfo();
            };
            BaseActivity.OnDestroyAction += (activity) =>
            BaseActivity.OnDestroyAction = (activity) =>
            {
                Console.WriteLine("OnDestroyAction");
                //BusSocket.Stop();
@@ -270,25 +296,25 @@
            };
            HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
            HDLUtils.SetAuthoritiesName("com.jinlu.onpro.fileProvider");
            //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 +436,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);
        }
    }
}