1

I am trying to make a service in a separate process which should be restarted after manual stop in task manager. Return of START_STICKY in onStartCommand() doesn't work for me. Here is the code:

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

Activity starts the service like this:

@Override
protected void onResume() {
    doStartService();

    super.onResume();
}

private void doStartService() {
    Intent intent = new Intent(getApplicationContext(), MyService.class);
    startService(intent);
    doBindService();
}

private void doBindService() {
    bindService(new Intent(this, MyService.class), mConnection, Context.BIND_AUTO_CREATE);
    mBound = true;
}

What can be wrong?

tshepang
  • 10,772
  • 21
  • 84
  • 127
Alex
  • 398
  • 5
  • 21
  • generally if a service is killed forcibly, it takes time for the service to be restarted on its own as the parameters android considers include are the importance and the space. – Rat-a-tat-a-tat Ratatouille Feb 08 '14 at 12:18
  • see this ans http://stackoverflow.com/questions/7257378/android-how-to-force-restart-of-a-service-os-killing-on-low-memory-behavior – Hardik Feb 08 '14 at 12:18

0 Answers0