简体   繁体   中英

How to create service likes of viber ,facebook which runs continuosly in background?

I am trying to make app which uses services.But i need services to run continously.I dont want it to be stop if i use 3rd party app such as 360 security ,task killer.I have created my services like this way.Thanks in advance.

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        super.onStartCommand(intent, flags, startId);
        return START_STICKY;
    }

I have used START_STICKY,but this doesnot help.

The START_STICKY return value has nothing to do with the continuous running of the service. It defines the behavior of the service when it is killed. (See here: official page ) Other information about services will also be there.

When you start a service with startService() the service will run until stopped by calling stopSelf() or stopService().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM