Skip to content

Android Service保活模块(5.0以下使用c来fork进程轮训监听,5.0以上使用KeepPushAliveJobSchedulerService来保活进程)

Notifications You must be signed in to change notification settings

superit/ServiceKeep

 
 

Repository files navigation

ServiceKeep

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

具体调用:

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,替换android:name为自己的业务类-->
<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" />

About

Android Service保活模块(5.0以下使用c来fork进程轮训监听,5.0以上使用KeepPushAliveJobSchedulerService来保活进程)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 78.8%
  • C 19.7%
  • Makefile 1.5%