0

How to enable autostart feature on a mobile phone through android studio so I can push notifications without troubling user by requesting them to turn on their autostart feature for my app.

Basically, this autostart feature is customized in ROM by the mobile companies to enhance their phone battery performance and other features etc. and because of this, I can't push notification when the app is killed I can only push notification when the app is running or is in the background and this becomes burden for developer to notify people of some important event or news even when the app is killed.

If autostart is disabled then all the services of the app are being killed and if I explicitly enable it then the push notification feature is working properly without any problem even when the app is not running at all or stopped or killed.

zero323
  • 322,348
  • 103
  • 959
  • 935
Akash
  • 75
  • 1
  • 8
  • I have never heard of AutoStart besides some 3rd party apps. If you want to have your app start on startup you can create a service & receiver and listen for BOOT_COMPLETED https://stackoverflow.com/questions/6391902/how-do-i-start-my-app-on-startup – jgetner Jan 27 '18 at 20:09
  • This solution doesn't work as whenever the user kills the app after using it I won't be able to send him any more notification again as services are being killed by the phone unless I explicitly enable autostart for the app. In stocked android, there is no problem at all you won't even have to do the BOOT_COMPLETED process. This problem is there in custom ROM. I hope u are understanding me. I use MIUI Global 9.2 | Stable 9.2.1.0 which is the latest version. http://en.miui.com/thread-117992-1-1.html – Akash Jan 27 '18 at 21:33
  • If enabling autostart feature is not possible programmatically then there should be a way to give an Intent to the activity where the user can explicitly enable it without troubling them to find this feature in the settings. How can I send intent to some specific activity on my phone is there a way if yes then I could figure out how to solve it. – Akash Jan 27 '18 at 21:37
  • I would take a second look at services and more specifically background services as they are capable of being ran in the background even after the app has been closed. The BOOT_COMPLETED would restart yoru service on start up and from your service you can then do what you need. https://developer.android.com/training/run-background-service/create-service.html – jgetner Jan 28 '18 at 00:16
  • Here is another good post about running a service forever which in background https://stackoverflow.com/questions/19345008/need-code-example-on-how-to-run-an-android-service-forever-in-the-background-eve – jgetner Jan 28 '18 at 00:19
  • By displaying ToastMessage I found out that even BroadcastReceiver doesn't respond when the app is killed that means I cannot even run the onReceive() method. Now, what shall I do? – Akash Jan 28 '18 at 12:55

0 Answers0