Android Question ”Hey Android vendors, don’t kill my app!”

Discussion in 'Android Questions' started by Sandman, Jan 15, 2019.

  1. Sandman

    Sandman Well-Known Member Licensed User

    This is a brand new site that I thought would be worth a visit from B4A users. It lists and ranks different phone vendors on how badly they cripple installed apps to squeeze out a little more battery.

    Don’t kill my app!
    https://dontkillmyapp.com/

    upload_2019-1-15_9-7-5.png


    The bigger question is, what can we as developers do about this? Here's some ideas on top of my mind:
    • Star their Github project, it helps bring attention to the project
    • Submit info you have on phones back to the project
    • Implement workarounds (some are suggested on the site)
    • Inform our users (gently) that their phone is overly aggressive
    • If you have a friend in the media that might be interested, point them to the site
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The proper way to run tasks in the background is with foreground services. Example: Background location tracking

    As a user, I'm not really happy with apps that run in the background, with the exception of very few types of apps (navigation for example).
     
    KMatle likes this.
  3. Sandman

    Sandman Well-Known Member Licensed User

    It was my impression that these devices kill even the apps doing this, are you saying it's not so?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I'm saying that this is the best way to run tasks in the background. It will work on most devices most of the time.
    The meaning of "kill an app" is not so simple. Is the app killed and later restarted? Maybe the app is only paused?
    I'm pretty sure that most new devices will not allow an app to prevent the device from sleeping without restrictions.

    Developers who own a Nokia device should try it and see whether the background location app continues to update the location after several hours.
     
  5. Sandman

    Sandman Well-Known Member Licensed User

    There is a posted issue in their Github project about whether foreground services would work to prevent the killing, and this was the response:

    We've tried this solution in our app, unfortunately with no luck. It does not prevent crappy manufacturer customization to kill the apps. For sure it's a bit better, but does not last more than one hour or 1 day...

    It's in fact the main goal of this project : the official Android documentation describe multiple solutions to keep our app alive and run our process (foreground service, task manager...) but it only works on stock Android. The manufacturers listed in the dont-kill-my-app project breaks the stock and documented behaviour.
     
  6. Pendrush

    Pendrush Well-Known Member Licensed User

    Almost all Xiaomi devices will kill app even if service is in Foreground. Half of Huawei device will kill app in foreground, 20% of Samsung low end devices will kill app in foreground.
    I have an app with foreground service and I have a lot of problem with named devices.
     
    peacemaker and corwin42 like this.
  7. Erel

    Erel Administrator Staff Member Licensed User

  8. Pendrush

    Pendrush Well-Known Member Licensed User

    I don't have any of these devices, but i have an app with 260k+ active installations, and all complains come from Xiaomi, Huawei and some low end Samsung devices, no matter of Android version.
    App is running music in foreground service with exo player. When user listening music after few minutes with screen turned off, device kill app. On some devices after 2 minutes, on some after 10 minutes. No trace of any error in foreground service in Crashlytics. I'm also using partial lock, and have test app on at least 10 different devices without problem. App running fine on most devices (have 4.8 average rate on play store).
     
    Peter Simpson, Sandman and Erel like this.
  9. Erel

    Erel Administrator Staff Member Licensed User

    The only thing that is done in the background location example and that you didn't mention is to use StartServiceAt to schedule the app to start every 30 minutes. This can help in some cases.

    However there is no doubt that running tasks on the background will not work reliably on all devices.
     
  10. Sandman

    Sandman Well-Known Member Licensed User

    Yes, that would be interesting to see if that made a difference for you, @Pendrush. Is that something you already do, perhaps? Willing to test, if you're not?

    Something else I was wondering, @Erel, and I do realize that this is difficult to answer without have a device to actually test on, but do you think that geofences still work as expected even though the device has overly aggressive killer instincts?
     
  11. Pendrush

    Pendrush Well-Known Member Licensed User

    I will try to include REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, maybe this help on problematic devices.
    App will be updated in this month. I will report back my conclusions.
     
    Sandman likes this.
  12. Sandman

    Sandman Well-Known Member Licensed User

    Thank you, that is very much appreciated.
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    This is a different case, more similar to push notifications. I guess that it will work better.
     
    Sandman likes this.
  14. ac9ts

    ac9ts Active Member Licensed User

    Be warned, The great Google flagged my app for having REQUEST_IGNORE_BATTERY_OPTIMIZATIONS and they requested I remove it. My app does the same as yours (plays streams with Exoplayer, foreground service, etc.) and I have the same issues with users saying the app shuts down after some time.
     
    peacemaker, Erel and Pendrush like this.
  15. Pendrush

    Pendrush Well-Known Member Licensed User

    Hmm I then have no other solution. Thanks for warning me.
     
  16. Erind Jushaj

    Erind Jushaj Member Licensed User

    Is there even a way to catch this closing event so that I get a warning everytime the app is killed?
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    No. The process is immediately killed.
     
  18. Sandman

    Sandman Well-Known Member Licensed User

    It's probably a good idea to remember that this behaviour is something implemented by the vendors to kill bad apps. (As I understand it, in China a lot of Android users are getting constantly bombarded by notification ads.) Therefore they aren't really aiming for a polite and developer friendly solution. They're bringing out the big guns, and us developers doing sane apps that actually provide value to the users are simply collateral damage.
     
  19. Erind Jushaj

    Erind Jushaj Member Licensed User

    Well that sucks because my app only lasts 15 minutes in forground and gets terminated..
     
  20. KMatle

    KMatle Expert Licensed User

    Could you describe what app is doing when running in foreground mode? Exactly: Why do you need to run it 24/7? I use FCM to trigger my apps when needed (e.g. new data, do some stuff in a service, etc.). Maybe we get closer to the problem via "what is an app doing vs. why is it killed".
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice