13

Is there any way to start service after user has manually stopped application using
Settings -> application -> manage application -> our app -> Force stop.

I want to restart my application after force close.

Is there any way to do the same?

John Conde
  • 217,595
  • 99
  • 455
  • 496
unflagged.destination
  • 1,576
  • 3
  • 19
  • 38
  • Have you looked into Android Services? I believe thiers a way to see if an Application is running. In the service you would say if the Application is not running then restart the Application. – Nate-Wilkins Oct 01 '12 at 17:30
  • there is a flag START_STICKY which starts service autometically when it stops, but it works only when application is running, not after force stop. – unflagged.destination Oct 02 '12 at 08:08
  • No no I'm saying have a service run in the background and restart a separate activity app. You'd still run into the problem that the user might stop your service but if that happens have the Application restart the service. – Nate-Wilkins Oct 02 '12 at 14:00
  • can we disable force stop button after setting our application as device administrator, may be there is some way to do this, 'kaspersky parental control' is doing the same. – unflagged.destination Oct 03 '12 at 15:32
  • the user will have to start the app once again in order for the service to start.even if start_sticky is used, i presume – Rat-a-tat-a-tat Ratatouille Nov 20 '13 at 10:23
  • Did you find an answer to this question? – Graeme May 13 '14 at 14:45

2 Answers2

4

You can't do this by starting two services because force stop will close all of your services related to the particular app which you are force stopping. So start the service when user opens the app again.

mmking
  • 1,564
  • 4
  • 26
  • 36
Suhail Mehta
  • 5,514
  • 2
  • 23
  • 37
  • 1
    Then how can work whatsapp application i force closed it many time still it show me notification. – Rana May 17 '16 at 06:51
  • 2
    @Rana there is always the possibility that Google is treating Whatsapp differently witouth saying it – lelloman Aug 21 '17 at 13:22
0

No, a service if Force Stopped can not be restarted automatically.

For more assistance you can go through this article:

http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/

kittu88
  • 2,451
  • 5
  • 40
  • 80
  • 1
    but there are some application like 'trend micro' which restarts itself after force close.Is there any other application or service which restarts it. I checked in logcat for trend micro, it writes something namely monitor just after force closing this application....Is that any other application which is hidden who is restarting trend micro after force close – unflagged.destination Oct 01 '12 at 11:55
  • You can try auto restarting the service. You can refer the link:http://blogmobile.itude.com/2012/02/20/automatically-starting-an-android-application-on-boot/ but still there is no guarantee about the service being activated every time. – kittu88 Oct 01 '12 at 12:10
  • thanks. it works but only when device restarted. but i need to restart app just after force close, so when user comes back to manage application -> app ,the force stop button should be enabled. – unflagged.destination Oct 01 '12 at 12:45