2

I've got some legacy code I'm working on that is triggered in onStop() method for my activity. When I put the app in the background using the home button, the onPause() followed by the onStop() methods are triggered in both non-lollipop and lollipop devices, and I get to clean up my activity. On non-lollipop devices when I receive a phone call, the onPause() - onStop() methods are called, and I get to clean-up my activity as expected. However, using lollipop, only the onPause() method is called when the phone call is received and accepted.

Has anyone else seen this, and have a work-around to this situation? Thanks.

4
  • can you use onPause only for the cleanup?
    – petey
    Commented Oct 27, 2014 at 21:25
  • how are you determining that onStop is not being called? Commented Oct 27, 2014 at 21:29
  • I'm using break points in onPause() and onStop() methods of my activity. The onStop() break point isn't being reached.
    – kralvarado
    Commented Oct 27, 2014 at 21:51
  • This is happening because phone calls in Lollipop are shown using a high priority notification that overlays your content (rather than opening a full-screen activity). In this case, since your Activity is still visible, but in the background, it is PAUSED, but not STOPPED. This avoids having your activity interrupted when a phone call comes in. I'm not sure why this is bad for your app, but it seems like you should let your app continue even when the call notification appears (since the user may not care, and just dismiss the call). Commented Oct 27, 2014 at 22:23

1 Answer 1

2

Register a BroadCastReciever for a Incoming call intent and do it in onRecieveIntent . Only a workaround though but will do the trick in all cases and all os versions.

3
  • This sounds like it may be the way to go, I'll test it out. Thanks.
    – kralvarado
    Commented Oct 27, 2014 at 21:56
  • Wanted to test out your suggestion before I marked it. Again, thanks for your answer.
    – kralvarado
    Commented Oct 28, 2014 at 18:27
  • No probs buddy happy coding :) Commented Oct 29, 2014 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.