0

I have a strange bug only producing on Android 10 while perfectly fine on Pie and Oreo. I am starting a call from Activity, when the call starts i want to minimize the call screen and get my activity back to foreground. My code to minimize call screen is below:

private void minimizeCallScreen(){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
  @Override
  public void run() {
   //intent to bring my activity to foreground
   Intent intent = new Intent(getApplicationContext(), MyActivity.class);
   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   startActivity(intent);
  }
}, 1000);

}

As soon as call starts, I call this method to minimize call screen, which is working perfectly fine on Oreo and Pie but on Android 10 it works only for the first time. It does not work when i start call 2nd time until i go back and recreate my activity. I have tried many different intent flags but nothing is working.

NOTE: This issue is Android 10 specific

  • You cannot start an activity from the background on Android 10: https://developer.android.com/about/versions/10/privacy/changes#background-activity-starts – CommonsWare Jan 10 '20 at 01:14
  • Thank you for sharing this link, Its really helpful but the thing i am wondering about is why it works for the first time but not when i press call button again in my activity? – Salahuddin Jan 10 '20 at 01:33
  • What can i do to achieve this. Is there any alternative? I don't want my activity in background during call. – Salahuddin Jan 10 '20 at 01:36

0 Answers0