| | |
| | | using Android.Content; |
| | | using Android.Net; |
| | | using Android.OS; |
| | | using CN.Jpush.Android.Api; |
| | | using CN.Jpush.Android.Service; |
| | | //using CN.Jpush.Android.Api; |
| | | //using CN.Jpush.Android.Service; |
| | | using Java.Lang; |
| | | using Java.Util; |
| | | using Java.Util.Zip; |
| | |
| | | [Android.App.Application] |
| | | public class Application : Android.App.Application |
| | | { |
| | | static void reStartApp (Android.App.Application application) |
| | | { |
| | | var intent = new Intent (application, typeof (BaseActivity)); |
| | | intent.AddFlags (ActivityFlags.NewTask); |
| | | application.StartActivity (intent); |
| | | Android.OS.Process.KillProcess (Android.OS.Process.MyPid ()); |
| | | } |
| | | |
| | | |
| | | public Application (IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base (handle, ownerShip) { } |
| | | public override void OnCreate () |
| | | { |
| | | initAll (); |
| | | if (Shared.Application.Activity != null) { |
| | | reStartApp (this); |
| | | return; |
| | | } |
| | | Shared.Application.IsGpsEnable = false; |
| | | |
| | | base.OnCreate (); |
| | | |
| | | initAll (); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | //BaseActivity.IsEnnableGPS = false; |
| | | //BaseActivity.VerifyDateTime = DateTime.MaxValue; |
| | | //BaseActivity.KeepScreenON = false; |
| | | |
| | | |
| | | |
| | | BaseActivity.BackKeyAction = () => { |
| | |
| | | BaseActivity.OnCreateActoin += (activity, application) => { |
| | | Microsoft.AppCenter.AppCenter.Start ("d0f0f0c5-88af-494b-93af-9a667801b7a3", typeof (Microsoft.AppCenter.Analytics.Analytics), typeof (Microsoft.AppCenter.Crashes.Crashes)); |
| | | //保存获取的极光服务器上的注册ID到本地文件 |
| | | var tokenID = JPushInterface.GetRegistrationID (activity); |
| | | if (!string.IsNullOrEmpty (tokenID) && UserConfig.Instance.tokenID != tokenID) { |
| | | UserConfig.Instance.tokenID = tokenID; |
| | | UserConfig.Instance.SaveUserConfig (); |
| | | } |
| | | //var tokenID = JPushInterface.GetRegistrationID (activity); |
| | | //if (!string.IsNullOrEmpty (tokenID) && UserConfig.Instance.tokenID != tokenID) { |
| | | // UserConfig.Instance.tokenID = tokenID; |
| | | // UserConfig.Instance.SaveUserConfig (); |
| | | //} |
| | | BaseActivity.NetworkStateChanged += (int obj) => { |
| | | Console.WriteLine ("NetworkStateChanged " + obj); |
| | | UserConfig.Instance.internetStatus = obj; |
| | |
| | | BaseActivity.OnDestroyAction += (activity) => { |
| | | BusSocket.Stop (); |
| | | }; |
| | | |
| | | HDLUtils.SetAuthoritiesName ("com.hdl.crabtree.fileProvider"); |
| | | |
| | | |
| | | } |
| | | public static bool IsShowTip = true; |
| | | void init () |
| | |
| | | Shared.Application.Skin = UserConfig.Instance.CurrentSkinName; |
| | | SkinStyle.Current.ChangeColor (); |
| | | UserConfig.Instance.phoneName = Android.OS.Build.Manufacturer; |
| | | //设置极光调试模式,为false时只打印警告信息 |
| | | JPushInterface.SetDebugMode (false); |
| | | JPushInterface.Init (this);//保存手机名称到本地文件 |
| | | ////设置极光调试模式,为false时只打印警告信息 |
| | | //JPushInterface.SetDebugMode (false); |
| | | //JPushInterface.Init (this);//保存手机名称到本地文件 |
| | | //获取经纬度 |
| | | Shared.Application.LocationAction = (arg1, arg2) => { |
| | | Shared.Application.LocationAction = null; |
| | | Shared.Application.StopGPSLocationService (); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | while (true) { |
| | | try { |
| | |
| | | void checkSomeInfo () |
| | | { |
| | | RemoteInfo.Current.ReadMsgList (UserConfig.Instance.tokenID, IsShowTip); |
| | | JPushInterface.ClearAllNotifications (this); |
| | | //JPushInterface.ClearAllNotifications (this); |
| | | |
| | | IsShowTip = true; |
| | | var status = isNetworkAvailable (this); |