Giter Site home page Giter Site logo

zylgithub / servicekeep Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xuningjack/servicekeep

0.0 2.0 0.0 192 KB

Android Service keep-alive module.(Android Service保活模块:5.0以下使用c来fork进程,5.0以上使用JobScheduler来保活进程)

Makefile 1.51% C 19.58% Java 78.91%

servicekeep's Introduction

ServiceKeep

Android Service保活模块(5.0以下使用c来fork进程,5.0以上使用JobScheduler来保活进程)

具体调用:

1、在WorkService的onStartCommand中执行要保活的操作业务。
2、在初始化过程中调用KeepAliveManager.INSTANCE.startKeepAliveService(context);
3、停止服务调用KeepAliveManager.INSTANCE.stopKeepAliveSerice(context);
4、配置AndroidManifest.xml,增加如下配置:
<!--增加唤醒WorkService的定时任务-->
<service
  android:name="jack.com.servicekeep.service.KeepAliveJobSchedulerService"
  android:persistent="true"
  android:exported="false"
  android:permission="android.permission.BIND_JOB_SERVICE"
  android:process="jack.com.servicekeep.job_scheduler_service"/>

<!--todo 自己业务保活的Service,重写WorkService中的onStartCommand其中执行自己的业务逻辑-->
<service
  android:name="jack.com.servicekeep.service.WorkService"
  android:exported="true"
  android:persistent="true"
  android:label="Jack"
  android:process="com.jack.workservice">
</service>

<!--开机启动监听-->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

开发常见异常:

1、由于小米系统的深度定制,使用方需要: 设置---自启动管理---选择应用(如jack.com.servicekeep)---打开自启动即可。
2、直接杀死什么进程,保活的是WorkService,不是demo。把demo干死了是不可以的,Android的底层机制。

servicekeep's People

Contributors

xuningjack avatar

Watchers

James Cloos avatar Ali avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.