Code Monkey home page Code Monkey logo

android-appdaemon's Introduction

Android-AppDaemon

App process daemon, used to keep your app alive.

Usage

  • This daemon can be added in application or service in your app, use Daemon.run(context, daemonServiceClazz, intervalTime) to run the daemon, then you can do something in onStartCommand of daemon service.
  • You need to add android:exported="true" to your daemon service in manifest so that daemon can start up your daemon service.
  • If you want to monitor the uninstall of app, see also Android-AppUninstallWatcher.

Note

This library dosen't work on all phones, such as xiaomi phones and Android 5.x.

Download

If you are building with Gradle, simply add the following line to the dependencies section of your build.gradle file:

compile 'com.coolerfall:android-app-daemon:1.2.0'

License

Copyright (C) 2015-2016 Vincent Cheung

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-appdaemon's People

Contributors

coolerfall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-appdaemon's Issues

how build

can you write about how huild the daemon?

java.lang.SecurityException

部分手机会有SecurityException的异常信息

Message: 
    Unable to create application com.skysea.skysay.base.BaseApp: java.lang.SecurityException: 
    Unable to start service Intent { cmp=com.skysea.skysay/.service.DaemonService }: Unable to launch app com.skysea.skysay/10101 for service Intent { cmp=com.skysea.skysay/.service.DaemonService }: user 0 is restricted

具体栈信息

Tue Mar 29 06:37:00 GMT+08:00 2016

Thread: 1

Message: Unable to create application com.skysea.skysay.base.BaseApp: java.lang.SecurityException: Unable to start service Intent { cmp=com.skysea.skysay/.service.DaemonService }: Unable to launch app com.skysea.skysay/10101 for service Intent { cmp=com.skysea.skysay/.service.DaemonService }: user 0 is restricted

Manufacturer: OPPO
Model: OPPO R7sm
Product: R7sm

Android Version: 5.1.1
API Level: 22
Heap Size: 256MB

Version Code: 29
Version Name: 2.9

Mac Address : dc6dcd914c46

Stack Trace:

java.lang.RuntimeException: Unable to create application com.skysea.skysay.base.BaseApp: java.lang.SecurityException: Unable to start service Intent { cmp=com.skysea.skysay/.service.DaemonService }: Unable to launch app com.skysea.skysay/10101 for service Intent { cmp=com.skysea.skysay/.service.DaemonService }: user 0 is restricted
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4783)
    at android.app.ActivityThread.access$1700(ActivityThread.java:164)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:159)
    at android.app.ActivityThread.main(ActivityThread.java:5541)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: java.lang.SecurityException: Unable to start service Intent { cmp=com.skysea.skysay/.service.DaemonService }: Unable to launch app com.skysea.skysay/10101 for service Intent { cmp=com.skysea.skysay/.service.DaemonService }: user 0 is restricted
    at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1769)
    at android.app.ContextImpl.startService(ContextImpl.java:1742)
    at android.content.ContextWrapper.startService(ContextWrapper.java:527)
    at com.skysea.skysay.base.BaseApp.onCreate(SourceFile:104)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4780)
    ... 9 more

间隔时间不起作用

Daemon.run(this, xx.class, Daemon.INTERVAL_ONE_MINUTE *1);
过了一分钟,进程并没有重启。

华为荣耀6上不起作用

你好,我用华为荣耀6测试,发现service不会被重启,不知道像个推这种推送sdk是怎么实现定时启动的。

大神

按大神你的方法,基本也实现我想要达到的目的。但是,如果我想在我的进程被杀之后,处理了一些事务,然后关闭这个Service,那该怎么办呢?我现在发现,这个Service怎么想死都死不了。

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.