0

i want to run a script even if the Task is destroyed. That works fine but is it possible to keep this service running, after the user destroyes the app? I read something about binding the service but this is not working for me.

polest
  • 51
  • 9
  • obviously not, that would be a security problem. i would delete the app but it would still have parts of it running. Also please clarify whether you mean destroy or deinstall. Those are not the same – Gavriel Feb 05 '16 at 15:04
  • 1
    Just want some clarification, what do you mean by "destroys app"? You mentioned deinstallation in the title but you talk about destroys app, which sounds like app has stopped running. – Alex Beggs Feb 05 '16 at 15:05
  • what do u mean by destroy app? – JAAD Feb 05 '16 at 15:06
  • i mean after the app is deinstallated. when the app is destroyed, my service still runs. – polest Feb 05 '16 at 15:26

1 Answers1

0

No. If the user uninstalls the app, all components are destroyed and removed from the operating system.

However, you can make a Service automatically restart after the app is killed (but not uninstalled) by starting through context.startService(Intent), and returning Service.START_STICKY in onStartCommand()

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;
}
Yaroslav Mytkalyk
  • 16,950
  • 10
  • 72
  • 99