79225772

Date: 2024-11-26 07:56:08
Score: 0.5
Natty:
Report link

I found a very elegant solution by using two libraries: https://github.com/judemanutd/AutoStarter AND https://github.com/XomaDev/MIUI-Autostart

First I check if my phone supports auto-start and then get the status of auto-start.

private fun checkAutoStartStatus() {
   if(AutoStartPermissionHelper.getInstance().isAutoStartPermissionAvailable(this)) {
        when (Autostart.getAutoStartState(this)) {
            Autostart.State.ENABLED -> {}
            Autostart.State.DISABLED -> {
               AutoStartPermissionHelper.getInstance().getAutoStartPermission(this)
            }
            Autostart.State.UNEXPECTED_RESULT,
            Autostart.State.NO_INFO -> {}
        }
    }
}
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Patrik Jurgelj