Esempio n. 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);
        }
Esempio n. 2
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);
        }