Android Question How to prevent a App from killing by Xiaomi (both MIUI and Hyper OS )

Mehrzad238

Active Member
Hello everyone.

I wrote an Alarm App, and it works, but when you want to close apps on Xiaomi, it doesn't just close them; it also kills them.
So I tried to enable Autostart, Disable battery restriction, and set it to no restriction.

It just dies like there is no such app in your phone, unless the user opens it and simply closes it by sliding to the top and not using the × at the bottom.
It might not happen after 1 or 2, but after multiple times it will

So I am open to any suggestion.
 

destinywood

New Member
Hello everyone.

I wrote an Alarm App, and it works, but when you want to close apps on Xiaomi, it doesn't just close them; it also kills them.
So I tried to enable Autostart, Disable battery restriction, and set it to no restriction.



It just dies like there is no such app in your phone, unless the user opens it and simply closes it by sliding to the top and not using the × at the bottom.
It might not happen after 1 or 2, but after multiple times it will



So I am open to any suggestion. geometry dash scratch
This problem isn't just confined to Xiaomi and MiUi.

I can name 3 other device manufacturers that kill smartwatch apps and connections, and they are all Chinese devices or owned by Chinese companies. I've found buying devices that DONT have a meditek chip with mediateks Duraspeed app does help although I have one device with a Unisoc SOC and android 13 which also keeps disconnecting my smart watch.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Hello everyone.

I wrote an Alarm App, and it works, but when you want to close apps on Xiaomi, it doesn't just close them; it also kills them.
So I tried to enable Autostart, Disable battery restriction, and set it to no restriction.

It just dies like there is no such app in your phone, unless the user opens it and simply closes it by sliding to the top and not using the × at the bottom.
It might not happen after 1 or 2, but after multiple times it will

So I am open to any suggestion.
Don't know if it works on every Xiaomi, but if you need it just for yourself try this:
After opening the app put it in background, swiping up if you use gesture or with the Home button.
Then open the recent used apps.
Long click on the image of the app of your interest and you should see some icons appear.
There should be an open lock.
Click to close the lock.
Now when you will try to kill all the recent apps, the ones with the lock will survive.
Even the system should not try to kill them.
 
Upvote 0

Mehrzad238

Active Member
Don't know if it works on every Xiaomi, but if you need it just for yourself try this:
After opening the app put it in background, swiping up if you use gesture or with the Home button.
Then open the recent used apps.
Long click on the image of the app of your interest and you should see some icons appear.
There should be an open lock.
Click to close the lock.
Now when you will try to kill all the recent apps, the ones with the lock will survive.
Even the system should not try to kill them.
Well, I was hoping to release, but with this issue, it's not gonna happen.
I want a solution for the users to use, but with a lot of complexity that kills the app, making it it is impossible.

I just want to say that I have tried like 10 different alarm apps from Google Play, and all of them had the same fate as mine. So I know for sure the problem is not with B4X, and it is with Chinese devices.
 
Upvote 0

Mehrzad238

Active Member
Have you tried applying this method?
https://www.b4x.com/android/forum/threads/background-location-tracking.99873/

Activating this only when there are alarms set.
Yes, that's exactly how I did. I even tried Service.StartForeground to see if that would prevent it, but :🔽

when you want to close apps on Xiaomi, it doesn't just close them; it also kills them.

And again :

It might not happen after 1 or 2, but after multiple times it will


I created the app with these two methods:

I used this method Start receiver at exact time
and this one for Calculating the next scheduled time

My business is not urgent, so for now I'm just gonna let it go, but if anyone finds a solution, we will all appreciate your effort
 
Upvote 0
Top