1

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)

  1. When tapped answer, immediately setting status PJSIP_SC_OK. (Sending 200 OK)
  2. Other person will respond back with 200 OK response.
  3. After that call state will be changed and captured that and sending to some other class to process.
  4. Passing the required message to Activity using handler.
  5. Activity which received the message will process according to that.
  6. 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,

  1. 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??

Sandhiya
  • 339
  • 2
  • 14
  • Please provide some code that you have tried, so that community can help you. – Piyush Jul 09 '20 at 10:42
  • @Piyush sure will update the post with adding code – Sandhiya Jul 09 '20 at 10:43
  • Most likely, your problem is with the activity, not the notification. Profile your activity and determine where the time is being taken when it is being displayed. – CommonsWare Jul 09 '20 at 10:52
  • @CommonsWare you are right. I have checked my code.. I got a white screen before launching activity for a sec. After that only my call connected screen shows up....I doesn't know how to overcome that – Sandhiya Jul 13 '20 at 06:28
  • Actually as @CommonsWare said, it's a start-up problem with your activity. You should profile to find out what is wrong with it. Using `android:windowDisablePreview` you can eliminate the white screen, but surely doesn't solve the main problem. I think another approach to show a window immediately is using a floating window which is full screen and seems like an activity. – aminography Jul 13 '20 at 08:19
  • May be you are doing too much on the main thread !! – kelvin Jul 16 '20 at 07:23
  • @aminography I solved the white screen problem...but not delay..I have edited my post plz look on that.. – Sandhiya Jul 16 '20 at 12:22
  • @kelvin edited my post plz look into that and see whether it helpful to understand my problem. – Sandhiya Jul 16 '20 at 12:24

2 Answers2

0

Without the source code it is a little difficult to suggest anything or attempt anything to fix the issue. Potentially create a pending intent with a bundle and utilize a broadcast receiver to handle the events with a custom broadcast?

MitchHS
  • 323
  • 1
  • 8
0

maybe because you do too much work in onCreate, and it delays rendering the view. Move some of that code out of onCreate and see if it can speed up.

Don Ha
  • 689
  • 5
  • 9