예제 #1
0
        private void StartStatusTimer()
        {
            if (_broadcastStatusTimer != null)
            {
                StopStatusTimer();
            }
            _broadcastStatusTimer = new Timer((o) =>
            {
                if (_core == null)
                {
                    if (CheckSelfPermission(Android.Manifest.Permission.WriteExternalStorage) == Android.Content.PM.Permission.Granted)
                    {
                        //Toast.makeText(getApplicationContext(), "Hello Javatpoint", Toast.LENGTH_SHORT).show();
                        _core = new BeatOnCore(this, _transciever.SendPackageInstall, _transciever.SendPackageUninstall);
                        _core.Start();
                    }
                }

                if (_core != null)
                {
                    _transciever.SendServerStatusInfo(new ServiceStatusInfo()
                    {
                        Url = _core.Url
                    });
                }
            }, null, 0, BROADCAST_STATUS_INTERVAL_MS);
        }
예제 #2
0
        public override void OnDestroy()
        {
            Log.LogMsg("BeatOnService OnDestroy called");
            StopStatusTimer();
            _transciever.UnregisterIntents();
            _transciever.Dispose();
            _transciever = null;

            //todo: shut down stuff here
            _core.Dispose();
            _core = null;
            base.OnDestroy();
        }
예제 #3
0
        private void StartStatusTimer()
        {
            if (_broadcastStatusTimer != null)
            {
                StopStatusTimer();
            }
            _broadcastStatusTimer = new Timer((o) =>
            {
                if (_core == null)
                {
                    if (CheckSelfPermission(Android.Manifest.Permission.WriteExternalStorage) == Android.Content.PM.Permission.Granted)
                    {
                        //Toast.makeText(getApplicationContext(), "Hello Javatpoint", Toast.LENGTH_SHORT).show();
                        _core = new BeatOnCore(this, _transciever.SendPackageInstall, _transciever.SendPackageUninstall, (x) => { _transciever.SendIntentAction(new IntentAction()
                            {
                                PackageName = x, Type = IntentActionType.Exit
                            }); });
                        _core.HardQuitTriggered += (s, e) =>
                        {
                            _transciever.SendHardQuit();
                            System.Threading.Timer tmr = null;
                            tmr = new Timer((z) =>
                            {
                                Log.LogMsg("App didn't kill the service after a miliseconds, service killing itself");
                                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                                Java.Lang.JavaSystem.Exit(0);
                                Log.LogMsg("Should be dead");
                                tmr.Dispose();
                            }, null, 300, Timeout.Infinite);
                        };
                        _core.Start();
                    }
                }

                if (_core != null)
                {
                    _transciever.SendServerStatusInfo(new ServiceStatusInfo()
                    {
                        Url = _core.Url
                    });
                }
            }, null, 0, BROADCAST_STATUS_INTERVAL_MS);
        }