0

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.

  • This might help : http://stackoverflow.com/questions/18572632/how-to-restart-android-service-when-it-is-killed-from-settings – Shivam Verma Jun 18 '14 at 06:38
  • 1
    What makes you think that they use Services? If you do some long running calculations, then yes, use Service, but if you want to be able to receive some notifications then you should use [BroadcastReceiver](http://developer.android.com/reference/android/content/BroadcastReceiver.html) – Marius Jun 18 '14 at 06:48
  • But in viber ,background services doesnot get closed even i used apps like 360 secuity.Is there any other idea for this – user3643493 Jun 18 '14 at 06:52

1 Answers1

0

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().

RaphMclee
  • 1,623
  • 13
  • 16