Cannot start Activity from Worker on xiaomi phones

100 views Asked by At

I am currently working on a video call app. I use FirebaseMessaingService to get the received message that the account is called, then start a Worker from the service, and then the worker starts an activity that displays a phone call. But it seems like it cannot start activity from service on Xiaomi devices. Could anyone help?

Xiaomi phones called workers successfully.

enter image description here

Before, Xiaomi couldn't even call Worker, but when I enabled autostart followed this question, it could.

2

There are 2 answers

1
tungnnnt17 On BEST ANSWER

I found the solution. Just go to Settings -> Permissions -> Other permissions -> App name -> enable "Display pop-up windows whie running in the background"

1
KenIchi On

Generally, you can't start an activity from background jobs (Worker, Service, etc..), it interrupts user's work. (Every version of Android make that stricter and stricter).

You need to make your app foreground to do that: for example Display over other apps, Foreground service.

Check out this: Start Activity from WorkManager API Level 29+