Exemple #1
0
        public override void OnReceive(Context context, Intent intent)
        {
            String action = intent.Action;

            Log.Debug(TAG, "onReceive:" + action);
            if (TextUtils.Equals(action, Intent.ActionScreenOff))
            {
                //息屏 开启
                KeepManager.GetInstance().StartKeep(context);
            }
            else if (TextUtils.Equals(action, Intent.ActionScreenOn))
            {
                //开屏 关闭
                KeepManager.GetInstance().FinishKeep();
            }
        }
Exemple #2
0
        public override void OnCreate()
        {
            base.OnCreate();

            //1像素广播注册
            KeepManager.GetInstance().RegisterKeep(this);

            //前台服务保活
            StartService(new Intent(this, typeof(ForegroundService)));

            //开启粘性服务进行保活
            StartService(new Intent(this, typeof(StickyService)));

            //使用JobScheduler进行保活
            AliveJobService.StartJob(this);

            //开启保活工作
            StartKeepWork();
        }
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Log.Debug(TAG, "AliveActivity启动");

            Window window = this.Window;

            window.SetGravity(GravityFlags.Start | GravityFlags.Top);
            WindowManagerLayoutParams @params = window.Attributes;

            //宽高
            @params.Width  = 1;
            @params.Height = 1;
            //设置位置
            @params.X         = 0;
            @params.Y         = 0;
            window.Attributes = @params;

            KeepManager.GetInstance().SetKeep(this);
        }