| | |
| | | using System; |
| | | using Android; |
| | | using Android.App; |
| | | using Android.Content; |
| | | using Android.Content.PM; |
| | | using Android.Locations; |
| | | using Android.Net; |
| | | using Android.OS; |
| | | using Android.Support.V4.App; |
| | | using Android.Support.V4.Content; |
| | | using CN.Jpush.Android.Api; |
| | | //using Android.Widget; |
| | | 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, 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.santan.smartcontrol.SplashActivity", ScreenOrientation = ScreenOrientation.Portrait)] |
| | | [IntentFilter(new string[] { "com.santan.smartcontrol.SplashActivity", Intent.ActionView })] |
| | | public class SplashActivity : Activity |
| | | { |
| | | protected override void OnActivityResult(int requestCode, Result resultVal, Intent data) |
| | |
| | | { |
| | | if (!OnAppConfig.Instance.FirstRunApp) |
| | | { |
| | | ////打开baseActivity |
| | | //打开baseActivity |
| | | Intent i = new Intent(this, typeof(BaseActivity));//Intent intent=new Intent( 起始组件对象 , 目标 Service.class); |
| | | StartActivityForResult(i, 1); |
| | | OverridePendingTransition(0, 0); |
| | |
| | | [Obsolete] |
| | | protected override void OnCreate(Bundle savedInstanceState) |
| | | { |
| | | Console.WriteLine("123456"); |
| | | 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); |
| | | Console.WriteLine("当前语言缩写:" + localeList.Language); |
| | | if (localeList.Language == "zh") |
| | | { |
| | | Language.CurrentLanguage = "Chinese"; |
| | |
| | | } |
| | | |
| | | Intent intent = new Intent(this, typeof(AgreementActivity)); |
| | | StartActivityForResult(intent,99); |
| | | StartActivityForResult(intent, 99); |
| | | } |
| | | else |
| | | { |
| | |
| | | initOhterSdk(); |
| | | Finish();//关闭自己 |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void Permissions() |
| | | { |
| | | string[] mPermissionList = new string[] |
| | | { |
| | | Manifest.Permission.ReadSms |
| | | }; |
| | | |
| | | foreach (string permissions in mPermissionList) |
| | | { |
| | | if (ContextCompat.CheckSelfPermission(this, permissions) != 0) |
| | | { |
| | | ActivityCompat.RequestPermissions(this, new string[] { permissions }, 1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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 |
| | |
| | | //#endif |
| | | JPushInterface.Init(this); |
| | | |
| | | //Com.Chteam.Agent.BuglyAgentHelper.Init(this.ApplicationContext, "316a8f5d83"); |
| | | |
| | | |
| | | BaseActivity.OnCreateActoin += (activity, application) => |
| | | { |
| | |
| | | |
| | | }; |
| | | |
| | | //初始化友盟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); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | }; |
| | | |
| | | BaseActivity.OnCreateActoin += (activity, application) => |
| | | BaseActivity.OnCreateActoin = (activity, application) => |
| | | { |
| | | Language.CurrentLanguage = "Chinese"; |
| | | Locale locale1 = Locale.Default; |
| | | var localeList = Resources.Configuration.Locale; |
| | | Console.WriteLine("当前语言编号"+ localeList.Language); |
| | | Console.WriteLine("当前语言编号" + localeList.Language); |
| | | if (localeList.Language == "zh") |
| | | { |
| | | Language.CurrentLanguage = "Chinese"; |
| | | } |
| | | else if(localeList.Language == "es") |
| | | { |
| | | Language.CurrentLanguage = "Spanish"; |
| | | } |
| | | else if (localeList.Language == "ru") |
| | | { |
| | | Language.CurrentLanguage = "russian"; |
| | | } |
| | | else if (localeList.Language == "bg") |
| | | { |
| | | Language.CurrentLanguage = "български"; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | BaseActivity.NetworkStateChanged += (int internetStatus) => |
| | | { |
| | | //if (!IsEnterBackground) |
| | | //{ |
| | | // ////BusSocket.Stop(); |
| | | // //new System.Threading.Thread(() => |
| | | // //{ |
| | | // // System.Threading.Thread.Sleep(1000); |
| | | // // //BusSocket.Start(); |
| | | // //}) |
| | | // //{ IsBackground = true }.Start(); |
| | | |
| | | //} |
| | | //else |
| | | //{ |
| | | //Console.WriteLine("HHH 网络变化但处于后台"+internetStatus); |
| | | //} |
| | | |
| | | //网络变化处理 |
| | | 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") |
| | | { |
| | | Language.CurrentLanguage = "Chinese"; |
| | | } |
| | | else if (localeList.Language == "es") |
| | | { |
| | | Language.CurrentLanguage = "Spanish"; |
| | | } |
| | | else if (localeList.Language == "ru") |
| | | { |
| | | Language.CurrentLanguage = "russian"; |
| | | } |
| | | else if (localeList.Language == "bg") |
| | | { |
| | | Language.CurrentLanguage = "български"; |
| | | } |
| | | else |
| | | { |
| | |
| | | MainPage.Show(); |
| | | checkSomeInfo(); |
| | | }; |
| | | BaseActivity.OnResumeAction += (activity) => |
| | | BaseActivity.OnResumeAction = (activity) => |
| | | { |
| | | checkSomeInfo(); |
| | | }; |
| | | BaseActivity.OnDestroyAction += (activity) => |
| | | BaseActivity.OnDestroyAction = (activity) => |
| | | { |
| | | Console.WriteLine("OnDestroyAction"); |
| | | //BusSocket.Stop(); |
| | |
| | | }; |
| | | |
| | | |
| | | HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider"); |
| | | HDLUtils.SetAuthoritiesName("com.santan.smartcontrol.fileProvider"); |
| | | |
| | | //Shared.Application.IsGpsEnable = true; |
| | | bool isfirst = 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; |
| | |
| | | MainPage.Log($"经纬度:::{lon}:{lat}"); |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | } |
| | | |
| | | public static bool IsShowTip = true; |
| | | |
| | | |
| | | void checkSomeInfo() |
| | | { |
| | | try |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 在你的活动(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); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |