setExactAndAllowWhileIdle() for alarmmanager is not working properly

后端 未结 3 562
野性不改
野性不改 2020-12-28 20:50

I am developing an app which needs to perform particular action on the exact time which user has set. For this i am using setExactAndAllowWhileIdle() method bec

3条回答
  •  太阳男子
    2020-12-28 21:17

    Some addition to @MarGin's answer.
    It's much easier for user to do all in one dialog but this violates the Google Play policy

    if (!powerManager.isIgnoringBatteryOptimizations(packageName)) {
        startActivity(
            Intent(
                Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,
                Uri.parse("package:$packageName")
            )
        )
    }
    

提交回复
热议问题