天道酬勤,学无止境

android-doze

Push notifications are delayed in Android Doze mode

I am putting my Android device to sleep via adb: adb shell dumpsys battery unplug adb shell dumpsys deviceidle step <-- repeat until state is IDLE Then I am sending the following JSON: { "to":"dYA7tVZrfag:APA91bFVqddVcJHnr_7ZhgNC5iu4Y6XKcLbSVD4DlZgfjMKwKvZhJHiKR4DIzpMrX8zUL15C_adfyEcrlI9q6zOFqFs_zwNPTVIDm-v20ZK0qgagKYGaQE1OPBqdH4P_JHYIXOIS3gfn", "priority": "high", "data":{ "test0":"test0", "test1":"test1" } } Result: Nothing... until I wake up the device, then I get all the messages queued. I am monitoring if messages are coming by putting logs in the method onMessageReceived(). I googled

2021-07-13 13:18:52    分类:问答    android   push-notification   firebase-cloud-messaging   android-doze

Doze mode on Oreo

I am facing issue in my app regarding doze mode. I am making a chat application and when app is in backgroud during doze mode and receive any message . Device does not show notification in orea. I have followed the proper procedure for OREO notification by building channel for it. I need to find if there is a way to whiteList my app from doze mode so that I can have notifications. Or any other process to optimize notification building.

2021-06-29 09:23:02    分类:问答    java   android   android-notifications   android-8.0-oreo   android-doze

Android Nougat PhoneStateListener 未触发(Android Nougat PhoneStateListener is not triggered)

问题 在 Android(目标 25)中,我有一个后台服务,在 onCreate 函数中,我已经初始化了一个电话状态侦听器。 它在 Nougat 之前的 Android 版本上运行良好,但在 Nougat 中它不起作用,即使授予了权限。 public class Service extends IntentService { class PhoneListener extends PhoneStateListener { String TAG = getClass().getName(); @Override public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: Log.d(TAG,"IDLE" ); break; case TelephonyManager.CALL_STATE_OFFHOOK: Log.d(TAG,"OFFHOOK"); break; case TelephonyManager.CALL_STATE_RINGING: Log.d(TAG,"RINGING"); break; }

2021-06-28 11:18:28    分类:技术分享    android   telephonymanager   android-7.0-nougat   android-7.1-nougat   android-doze

如何以编程方式关闭棉花糖设备中特定应用程序的瞌睡模式(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

如何在打盹模式下移动设备 (Android Preview M / Marshmallow)?(How to shift device in Doze Mode (Android Preview M / Marshmallow)?)

问题 我按照此处描述的步骤操作: https://developer.android.com/preview/testing/guide.html#doze-standby 情况: Android 调试桥版本 1.0.32 带有预览版 M 的 Nexus 9 壳: $ adb shell dumpsys battery unplug => 工作,设备已拔掉 $ adb shell dumpsys deviceidle step => 输出:步进到:ACTIVE $ adb shell dumpsys deviceidle -h => 不起作用 => 输出: Device idle controller (deviceidle) dump options: [-h] [CMD] -h: print this help text. Commands: step disable enable whitelist 我试过: adb shell dumpsys deviceidle enable 但它没有用。 所以我的问题,如上所述,如何在打盹模式下移动设备? 我做错了什么? 编辑 - 2016 年 6 月: 新链接:https://developer.android.com/training/monitoring-device-state/doze-standby.html 回答1

2021-06-22 08:11:25    分类:技术分享    android   android-6.0-marshmallow   android-doze

Android 7.0 Doze is it stop all notification?

I am trying to learn Android 7.0 but i see this comment. "When a device is on battery power, and the screen has been off for a certain time, the device enters Doze and applies the first subset of restrictions: It shuts off app network access, and defers jobs and sync" I dont understand exactly. İf it stop network in Doze mode ,how can i get whatsapp or email push message. Is it also restrict all in this mode? Thank you for comment

2021-06-12 10:00:39    分类:问答    android   android-7.0-nougat   android-doze

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

如何正确触发ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS意向?(How do I properly fire ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent?)

问题 如文档中所述: “拥有REQUEST_IGNORE_BATTERY_OPTIMIZATIONS权限的应用程序可以触发系统对话框,使用户可以直接将应用程序添加到白名单,而无需进行设置。该应用程序将触发ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS意图来触发对话框。” 有人可以告诉我激发这种意图的正确方法吗? 回答1 Intent intent = new Intent(); String packageName = context.getPackageName(); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); else { intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); }

2021-05-08 16:52:59    分类:技术分享    android   android-intent   optimization   android-6.0-marshmallow   android-doze

How to test Doze Mode on Android?

There is an old Android app which work background 2 service (Service). It took to update the app with the possibility of sending data and logging while working is not a new DozeMode. Before you amend the current code I decided to check how everything will work now. To run the application, in the logs I see that both services are running (the basic meaning of the service to read the position of the device, the second service sends the data to the server). Turn off the screen with the command adb shell dumpsys deviceidle step translate the system to DozeMode: Nikita:app NG$ adb shell dumpsys

2021-04-27 22:56:21    分类:问答    android   android-service   adb   android-doze

How to shift device in Doze Mode (Android Preview M / Marshmallow)?

I followed steps described here: https://developer.android.com/preview/testing/guide.html#doze-standby Circumstances: Android Debug Bridge version 1.0.32 Nexus 9 with Preview M Shell: $ adb shell dumpsys battery unplug => worked, device unplugged $ adb shell dumpsys deviceidle step => Output: Stepped to: ACTIVE $ adb shell dumpsys deviceidle -h => does not work => Output: Device idle controller (deviceidle) dump options: [-h] [CMD] -h: print this help text. Commands: step disable enable whitelist I tried it with: adb shell dumpsys deviceidle enable But it didn't work. So my question, as

2021-04-22 08:25:21    分类:问答    android   android-6.0-marshmallow   android-doze