天道酬勤,学无止境

android-appstandby

如何以编程方式关闭棉花糖设备中特定应用程序的瞌睡模式(how to turn off doze mode for specific apps in marshmallow devices programmatically)

问题 Marshmallow API 与之前的安卓操作系统有很大不同。 屏幕关闭时,设备处于休眠模式且无法同步网络。 因此,为了使用网络进行后台操作,我们必须防止打瞌睡模式。 回答1 将以下权限添加到 manifest.xml <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/> 调用下面的方法 public void turnOffDozeMode(Context context){ //you can use with or without passing context if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Intent intent = new Intent(); String packageName = context.getPackageName(); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) // if you want to desable doze

2021-06-24 09:58:17    分类:技术分享    android   android-6.0-marshmallow   android-doze   android-appstandby

Remove app from whitelist in android marshmallow

I didn't find useful info how to programically or using device's settings remove specific app from white-listed. In android 6.0 was introduced doze-mode and while-listed, the last term allows ignore partially doze-mode. To put app in white-listed apps need to perform code: Intent intent = new Intent(); intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + getPackageName())); startActivity(intent); I tried next actions to remove the app from white-listed, which it has just been put, but nothing help me: clear data application in settings

2021-05-14 09:49:03    分类:问答    android   android-doze   android-appstandby

Android - Disable Forced DozeMode or AppStandByMode

I have an application that uses a ForegroundService to send location updates to a server. Basically a tracker. This ForegroundService has a Handler that periodically (using postDelayed) executes a block of code to send the location. This works perfectly fine, when the app is in the foreground and even in the background, but I started to notice a delay when the phone is locked, with the screen off for about 15minutes. I mean, 15 minutes of no user activity and no charger plugged. This is happening on a Android Q (v10) device. I'm assuming this would also happen on any device running Oreo

2021-04-21 13:20:19    分类:问答    android   android-doze   battery-saver   android-doze-and-standby   android-appstandby

how to turn off doze mode for specific apps in marshmallow devices programmatically

Marshmallow APIs are very different from previous android OS. When screen is off, devices are in doze mode and unable to sync network. So for doing background operations with network we have to prevent from doze mode.

2021-04-19 03:16:33    分类:问答    android   android-6.0-marshmallow   android-doze   android-appstandby