protected override void OnStart() { base.OnStart(); if (_broadcastReceiver == null) { _broadcastReceiver = new BeatOnServiceTransceiver(this); _broadcastReceiver.ServiceStatusInfoReceived += (o, e) => { //_webView.LoadUrl($"http://localhost:50000"); _webView.LoadUrl(e.Url); _broadcastReceiver.UnregisterIntents(); _broadcastReceiver.RegisterContextForIntents(BeatOnIntent.InstallPackage, BeatOnIntent.UninstallPackage); _broadcastReceiver.UninstallPackageReceived += (s, p) => { BeatSaberModder m = new BeatSaberModder(this, null, null); m.TriggerPackageUninstall(p.PackageUrl); }; _broadcastReceiver.InstallPackageReceived += (s, p) => { BeatSaberModder m = new BeatSaberModder(this, null, null); m.TriggerPackageInstall(p.PackageUrl); }; _broadcastReceiver.HardQuitReceived += (s, i) => { Intent serviceToStart = new Intent(this, typeof(BeatOnService)); Log.LogMsg("Stopping service"); StopService(serviceToStart); Log.LogMsg("Service Stopped"); Log.LogMsg("Killing app"); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); Java.Lang.JavaSystem.Exit(0); Log.LogMsg("Should be dead"); }; _broadcastReceiver.IntentActionReceived += (s, i) => { if (i.Type == IntentActionType.Exit) { var intent = new Intent("com.oculus.system_activity"); intent.SetPackage(i.PackageName); intent.PutExtra("intent_pkg", "com.oculus.vrshell"); intent.PutExtra("intent_cmd", "{\"Command\":\"exitToHome\", \"PlatformUIVersion\":3, \"ToPackage\":\"" + i.PackageName + "\"}"); SendBroadcast(intent); intent.PutExtra("intent_cmd", "{\"Command\":\"returnToLauncher\", \"PlatformUIVersion\":3, \"ToPackage\":\"" + i.PackageName + "\"}"); SendBroadcast(intent); } }; }; } if (!_broadcastReceiver.IsRegistered) { _broadcastReceiver.RegisterContextForIntents(BeatOnIntent.ServerStatusInfo); } //if (_serviceConnection == null) //{ // this._serviceConnection = new BeatOnServiceConnection(this); //} //string s = _serviceConnection.WebUrl; }
protected override void OnStart() { base.OnStart(); if (_broadcastReceiver == null) { _broadcastReceiver = new BeatOnServiceTransceiver(this); _broadcastReceiver.ServiceStatusInfoReceived += (o, e) => { //_webView.LoadUrl($"http://localhost:50000"); _webView.LoadUrl(e.Url); _broadcastReceiver.UnregisterIntents(); _broadcastReceiver.RegisterContextForIntents(BeatOnIntent.InstallPackage, BeatOnIntent.UninstallPackage); _broadcastReceiver.UninstallPackageReceived += (s, p) => { BeatSaberModder m = new BeatSaberModder(this, null, null); m.TriggerPackageUninstall(p.PackageUrl); }; _broadcastReceiver.InstallPackageReceived += (s, p) => { BeatSaberModder m = new BeatSaberModder(this, null, null); m.TriggerPackageInstall(p.PackageUrl); }; }; } if (!_broadcastReceiver.IsRegistered) { _broadcastReceiver.RegisterContextForIntents(BeatOnIntent.ServerStatusInfo); } //if (_serviceConnection == null) //{ // this._serviceConnection = new BeatOnServiceConnection(this); //} //string s = _serviceConnection.WebUrl; }
public override void OnCreate() { //hook up handlers for all avenues of otherwise uncaught exceptions to make sure they get logged. AppDomain.CurrentDomain.UnhandledException += (sender, ex) => { var castEx = ex.ExceptionObject as Exception; if (castEx != null) { Log.LogErr("-------------------> AppDomain.CurrentDomain.UnhandledException!", castEx); } else { Log.LogErr("-------------------> AppDomain.CurrentDomain.UnhandledException! Exception Object was not an exception or was null!"); } try { if (_fileLogger != null) { _fileLogger.Flush(); } } catch { } }; TaskScheduler.UnobservedTaskException += (sender, ex) => { Log.LogErr("-------------------> TaskScheduler.UnobservedTaskException!", ex.Exception); try { if (_fileLogger != null) { _fileLogger.Flush(); } } catch { } }; AndroidEnvironment.UnhandledExceptionRaiser += (sender, ex) => { Log.LogErr("-------------------> AndroidEnvironment.UnhandledExceptionRaiser!", ex.Exception); try { if (_fileLogger != null) { _fileLogger.Flush(); } } catch { } }; Log.LogMsg("BeatOnService OnCreate called"); // This method is optional to implement base.OnCreate(); _transciever = new BeatOnServiceTransceiver(this); _transciever.RegisterContextForIntents(BeatOnIntent.DownloadUrl, BeatOnIntent.ImportConfigFile, BeatOnIntent.RestartCore); _transciever.RestartCoreReceived += (e, a) => { //TODO: }; _transciever.DownloadUrlReceived += (e, a) => { if (_core != null) { _core.DownloadUrl(a.Url, a.MimeType); } }; //TODO: import config file StartStatusTimer(); }