Showing posts with label lifecycle. Show all posts
Showing posts with label lifecycle. Show all posts

Sunday, April 8, 2012

Android lifecycle weirdness with singleTop and foreground service?


Here's the scenario:



  • Start Activity A

  • Activity A starts service S

  • Service S runs in foreground mode and shows up a notification which when pressed takes the user to Activity B (which has launchMode="singleTop")

  • Activity B shows up

  • Press HOME

  • Go into DDMS and kill your application process to simulate that your app died (press red STOP button)

  • Android will say "Rescheduling crashed service in 5000ms" (sometimes longer)

  • Service S restarts and notification is shown.

  • Press the notification icon when the service restarts...