Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart app if it unexpectedly shutdown

Skype update text contains next:

App auto restarts if unexpectedly shut down

How is possible to perform that via SDK?

like image 728
Maxim Kholyavkin Avatar asked May 01 '12 08:05

Maxim Kholyavkin


People also ask

What do you do when an app shuts down?

The easiest way to fix an app that keeps crashing on your Android smartphone is to simply force stop it and open it again. To do this, go to Settings -> Apps and select the app that keeps crashing. Tap on the app's name and then tap on 'Force stop'. Now try opening the app again and see if it works well.

Why do apps unexpectedly quit?

In some instances, an app may force close, crash, frequently freeze or stop responding, or generally not work as the app was designed. This can be caused by many factors, but most app issues can be fixed by updating the software or clearing the app data.

What do you do when an app won't open?

You can perform a soft reboot by long-pressing the power button and selecting Restart or swiping the app-shade down, selecting the power icon, and then choosing Restart. Older Android phones use the power button method; more recent models use the app-shade method.


2 Answers

As far as I know, some sort of apps can be run in background and can be restarted in specific case. This is from Apple docs

https://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/uid/TP40007125

If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the application:didFinishLaunchingWithOptions: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event.

My opinion is: Skype is relaunched with remote notifications mechanism.

Update

Well, I think I found something. @Malek_Jundi was half-right. Your app should fail with non-zero exit code, but it should be registered as VoIP application.

Because VoIP applications need to stay running in order to receive incoming calls, the system automatically relaunches the application if it exits with a nonzero exit code. (This could happen in cases where there is memory pressure and your application is terminated as a result.) However, terminating the application also releases all of its sockets, including the one used to maintain the VoIP service connection. Therefore, when the application is launched, it always needs to create its sockets from scratch.

http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW12

like image 100
anticyclope Avatar answered Nov 15 '22 19:11

anticyclope


Skype does exactly this:

  1. Registers it's TCP sockets for VoIP.
  2. Logs in.
  3. Upon nonzero exit code the app will be relaunched by iOS (Because VoIP applications need to stay running in order to receive incoming calls, the system automatically relaunches the application if it exits with a nonzero exit code.).
  4. It then immediately starts a background task (Relaunched apps remain suspended).
  5. Next it registers it's login socket for VoIP.
  6. It logs back in.
like image 27
junglecat Avatar answered Nov 15 '22 18:11

junglecat