/* Called when the activity is first created. */ protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //// 隐藏标题栏 //this.RequestWindowFeature(WindowFeatures.NoTitle); //// 隐藏状态栏 //this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); //// 将背景设置为空 //this.Window.SetBackgroundDrawable(null); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // 判断SD卡是否存在 if (Android.OS.Environment.ExternalStorageState == Android.OS.Environment.MediaMounted) { // 设置APP目录 Settings.AppPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/" + GetString(Resource.String.ApplicationName); using (File file = new File(Settings.AppPath)) { if (!file.Exists()) { bool bSuccess = file.Mkdirs(); // If failed, do something //this.Finish(); } } } else // SD卡不存在 { // 设置为当前目录 Settings.AppPath = "./" + GetString(Resource.String.ApplicationName); } // 心跳线程 if (HeartBeatThread == null) { HeartBeatThread = new Java.Lang.Thread(() => { bIsHeartBeatThreadOn = true; while (bIsHeartBeatThreadOn) { System.Threading.Thread.Sleep(Settings.HeartBeatRate); MemoryCheck(); HeartBeat(); } }); } if (!HeartBeatThread.IsAlive) { HeartBeatThread.Start(); } // 初始化首页布局 InitMainLayout(); }
/* Called when the activity is first created. */ protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // 隐藏标题栏 this.RequestWindowFeature(WindowFeatures.NoTitle); // 隐藏状态栏 this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); // 将背景设置为空 this.Window.SetBackgroundDrawable(null); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // 获取启动方式 string mode = null; if (Intent.Extras != null) { mode = Intent.Extras.GetString("mode"); } // 解析启动方式 if (ParseMode(mode) == 1) { // 开机自启动:未完全生效,后台运行 // 故重启! //RestartApp(); //// 重启后亦不生效,自杀后,通过守护进程开启 //Settings.RuntimeLog.Info("重启后亦不生效,自杀后,通过守护进程开启"); //Daemon(); // 关闭前,查看守护进程 //Finish(); //System.Threading.Thread.Sleep(8); //Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); //return; } // 节目控制线程 if (ProgramControlThread == null) { ProgramControlThread = new Java.Lang.Thread(() => { bIsProgramControlThreadOn = true; while (bIsProgramControlThreadOn) { System.Threading.Thread.Sleep(2000); ProgramControl(); } }); } if (!ProgramControlThread.IsAlive) { ProgramControlThread.Start(); } // 心跳线程 if (HeartBeatThread == null) { HeartBeatThread = new Java.Lang.Thread(() => { bIsHeartBeatThreadOn = true; while (bIsHeartBeatThreadOn) { System.Threading.Thread.Sleep(Settings.HeartBeatRate); MemoryCheck(); HeartBeat(); //if (IsTimePointIn(DateTime.UtcNow)) if (IsTimePointIn(DateTime.Now)) { // 01:30~6:30 关闭程序 Settings.RuntimeLog.Info("01:30~6:30 关闭程序"); Daemon(); // 关闭前,查看守护进程 Finish(); System.Threading.Thread.Sleep(8); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); } } }); } if (!HeartBeatThread.IsAlive) { HeartBeatThread.Start(); } //// WebSocket线程 //if (WebSocketThread == null) //{ // WebSocketThread = new Java.Lang.Thread(() => // { // WebSocketHandler(); // }); //} //if (!WebSocketThread.IsAlive) //{ // WebSocketThread.Start(); //} }