用户睡眠时在BLE监视应用程序上处理Android-Doze模式 [英] Dealing with Android-Doze mode on my BLE monitoring app while user's sleeping

查看:172
本文介绍了用户睡眠时在BLE监视应用程序上处理Android-Doze模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制造了一种在睡眠时间监控人的健康的设备,并通过BLE连接到智能手机.

I made the device which monitors person's health in sleep time and it connects to a smartphone via BLE.

与iOS应用配合使用效果很好. 但是自从Doze模式出现在Android世界上以来. 真的很难处理,因为我的设备在他的睡眠时间内可以正常工作.

It's working great with the iOS app. But since Doze mode came on Android world. It's really hard to deal with it because my device is working in his sleep time.

主要功能是,它可以检测到特定危险,并在用户与设备一起睡眠时通知用户.发生时我需要网络连接.

The main feature is that it detects particular danger and notify to the user while he is sleeping with the device. I need a network connection when it occurs.

许多文章告诉我,即使我的应用程序在白名单中,我也可以在打ze睡模式下使用网络.但是在我测试打ze模式后,情况似乎并非如此. 我说的对吗?

Many articles tell me that I can use a network even in the doze mode if my app is in the whitelist. But it does not seem true after I tested Doze mode. Am I right?

我可以确保在触发时可以在列表中找到我的应用程序

I can ensure that I can find my app in the lists, when I fire

adb shell dumpsys deviceidle

adb shell dumpsys deviceidle

使我的应用正常运行的最佳方法是什么?

  • 前景服务
  • 具有SetExactAndAllowWhileIdle的
  • 警报管理器.
  • GCM(意思是推,对吧?)
  • 还有什么
  • What is the best approach that I can take to make my app working correctly?

    • foreground services
    • alarm manager with SetExactAndAllowWhileIdle.
    • GCM (it means push, right?)
    • anything else
    • 任何提示都会对我有所帮助. 谢谢.

      Any tips will help me. Thanks.

      不幸的是,我使用GCM进行了测试,但它只会在很短的时间内唤醒我的应用程序.这意味着我必须发送尽可能多的GCM以保持其清醒状态.我认为我无法使用它.

      Unfortunately, I tested with using GCM but it only wakes my app in short time. It means I have to send GCM as many as I want to keep it awake. I don't think I can use it.

      推荐答案

      许多文章告诉我,即使我的应用程序在白名单中,我也可以在打ze睡模式下使用网络.但是在我测试打ze模式后,情况似乎并非如此.我说的对吗?

      Many articles tell me that I can use a network even in the doze mode if my app is in the whitelist. But it does not seem true after I tested Doze mode. Am I right?

      您说的不对.当您的应用程序进入白名单时,解除休眠的限制之一就是在休眠状态下使用网络的能力.

      You are not right. One of the restrictions of doze that are lifted when your app is on the whitelist, is the ability to use the network when doze is active.

      被列入白名单的应用程序可以在打and和应用程序待机期间使用网络并持有部分唤醒锁.但是,其他限制仍然适用于列入白名单的应用程序,就像对其他应用程序一样.例如,列入白名单的应用程序的作业和同步被推迟(在API级别23及以下),并且其常规AlarmManager警报不会触发.

      An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby. However, other restrictions still apply to the whitelisted app, just as they do to other apps. For example, the whitelisted app’s jobs and syncs are deferred (on API level 23 and below), and its regular AlarmManager alarms do not fire.

      来自此处 .

      换句话说:如果您在白名单上,则应该可以在打ze睡时使用网络.

      In other words: you should be able to use the network in doze if you are on the whitelist.

      让我的应用正常运行的最佳方法是什么?

      What is the best approach that I can take to make my app working correctly?

      考虑到您的应用是运行状况监控器,因此应该能够持续或至少非常定期地执行其工作,您可以将功能放在前台服务中.前景服务不受打ze的影响.

      Considering your app is a health monitor and thus should be able to do its work constantly or at least very regularly, you could put the functionality in a foreground service. Foreground services are not effected by doze.

      您应该意识到,应该有充分的理由使用前台服务,因为用户已经知道它们,但是我认为您的其中一项具有运行状况监视功能.

      You should be aware that you should have a good reason to use a foreground service since the user is aware of them, but I think you have one with the health monitoring etc.

      注意:仅应将前台服务用于用户希望系统立即执行或不中断执行的任务.这样的情况包括将照片上传到社交媒体,或者即使音乐播放器应用程序不在前台也可以播放音乐.您不应仅仅为了防止系统确定您的应用程序处于空闲状态而启动前台服务.

      Note: You should only use a foreground service for tasks the user expects the system to execute immediately or without interruption. Such cases include uploading a photo to social media, or playing music even while the music-player app is not in the foreground. You should not start a foreground service simply to prevent the system from determining that your app is idle.

      来自此处 .

      这篇关于用户睡眠时在BLE监视应用程序上处理Android-Doze模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆