Reputation: 3527
I'm working on an Android app that streams video to a remote server. My current problem is that when a call is received while working with the camera, my activity looses focus to the phone app and therefore, no streaming can be done while the phone rings (or while the use is during the call). I would like to intercept the incoming call and allow the user to decide whether to accept it or not from within my activity.
I know I can use the a broadcast intent for being notified for an incoming phone call but is it possible to prevent from the phone app to take focus? can I "reject" the call from my app upon user decision?
Thanks.
Upvotes: 1
Views: 2449
Reputation: 8079
You need to implement this in a service.
Services are not interrupted by things like incoming calls. You can still control your UI via broadcasts to your activity and keep the user updated. Then when the activity is interrupted by the system, the streaming will continue in the service, and you can resume updating the user interface when the activity resumes (ie when the user hangs up).
You should really avoid interfering with the expected behavior of the operating system, such as intercepting an incoming call, most likely the user will just get annoyed with your app, which will lead to bad ratings or uninstalls.
I can recommend also reading Multitasking the Android Way for a better explanation.
Upvotes: 1