There is restriction in launching activities from background in Android 10. I am working on Voip calling app. So due to this restriction I have started Activity from Service through pending intent. Whenever user clicks answer in Heads up Notification, I will direct them to specific activity.
My Problem is, after tapping on Answer action in notification, Activity is not launched quickly. First a white screen is visible and then loading activity. Due to that, call duration for Person A and B differs. Also loading call activity after a delay is not a good one.
In whatsapp once I tap answer, immediately activity launched meantime call duration also started. So its really good. I didn't face any delay for loading activity and call duration timer in whatsapp.
How can I achieve like that in my app. Please anybody help me with this.
I have tested answering incoming call from Notification in two different devices in version 10 and 8. Below is the process of answering incoming call.(I am using Pjsip Library)
- When tapped answer, immediately setting status PJSIP_SC_OK. (Sending 200 OK)
- Other person will respond back with 200 OK response.
- After that call state will be changed and captured that and sending to some other class to process.
- Passing the required message to Activity using handler.
- Activity which received the message will process according to that.
- If the activity received confirmed message for call, then only setting screen for call connected state and then starting timer....
Time taken for starting timer in call connected screen after the first step mentioned above is 1.xx secs(Android 10) and 2secs(Android 8).
In Activity's onCreate I am doing below works before showing layout,
- Setting views visibility, setting image and also used Bitmap to resize image. When tested Found 0.65 secs taken for processing Activity's Oncreate in Oreo version meanwhile in Q version only takes 0.27 secs. Not only oreo but also in some older versions.
Thatswhy I am getting time difference...What can I do ??
Once user tap answer in notification, I need to show call connected screen without any delay and without white screen. Whatsapp able to achieve dat. So how can I achieve that in my voip calling app??