行为识别PendingIntent站被称为在半夜 [英] Activity Recognition PendingIntent stop been called in the middle of the night

本文介绍了行为识别PendingIntent站被称为在半夜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序定期收集行为识别所检测到的活动数据。 我实现了它描述href="http://developer.android.com/training/location/activity-recognition.html" rel="nofollow">,但一分钟的间隔

my application collects periodically Activity Recognition's Detected activity data. I implemented it exactly as described in the documentation , but with one minute interval.

只要用户登录 - 与注册的应用程序中的 PendingIntent 来接收来自谷歌的更新过程中起到..

as long as the user is logged in - the application registered with a PendingIntent to receive updates from google play process..

请没有训斥我关于电池的使用,网络和性能问题从请求派生更新每分钟,除非它有话跟我的问题:

please not lecture me about battery usage, network, and performance problem derived from request updates each minute, unless it have something to do with my problem:

问题:在某些设备(在Nexus的5碰巧最),为5-6小时,在半夜 - 的 IntentService 停止被调用。

the problem: in some devices (in Nexus 5 it happens the most), for a 5-6 hours in the middle of the night - the IntentService stopped been called.

我不知道,但怀疑它有一些做与谷歌的优化和显著的运动传感器没有检测到进入活动识别机制,在某种空闲模式下的任何运动,因为这可以发生的文档中描述。

I'm not sure, but suspects it have something to do with Google optimizations and the significant motion sensor not detecting any motion entering the activity recognition mechanism to be in sort of idle mode, as described in the documentation that can happened.

重要的是要我的应用程序才知道什么是当前活动每分钟约即使保持不变,或闲置了很长的时间。

我的问题:

  • 我怎么能知道是否定期活动终止确认被调用,因为显著运动传感器或任何其他原因?
  • 在它有没有办法以某种方式迫使谷歌播放过程中进行的活动更新,而不停止它因为它假定并不需要一个时间?

推荐答案

每<一href="http://developer.android.com/reference/com/google/android/gms/location/ActivityRecognitionClient.html#requestActivityUpdates%28long,%20android.app.PendingIntent%29"相对=nofollow> ActivityRecognitionClient.requestActivityUpdates :

要节省电池,活动报告时可能会停止该设备STILL的时间过长。它将继续一旦设备再次移动。这只发生在支持Sensor.TYPE_SIGNIFICANT_MOTION硬件设备。

To conserve battery, activity reporting may stop when the device is 'STILL' for an extended period of time. It will resume once the device moves again. This only happens on devices that support the Sensor.TYPE_SIGNIFICANT_MOTION hardware.

正如你怀疑的。没有理由使用的许多数据存储技术,你不能保存的最后一个值 - 一个简单的共享preference 可能是足够你的情况。

As you suspected. There's no reason you cannot save the last value using the many data storage techniques - a simple SharedPreference might be enough for your case.

如果您是直接触发的基础上IntentService行动被称为(一个糟糕的主意,因为其他应用程序可能会导致其极快地触发),而不是只对变化的活动,那么你应该去耦这些行动,而是的设定闹铃或触发的定期同步适配器以任何特定的时间间隔需要,阅读所收到的最后一个活动的当前值。

If you are directly triggering actions based on the IntentService being called (a bad idea since other apps may cause it to trigger extremely quickly) rather than only on changes in activity, then you should decouple those actions and instead set an alarm or trigger a periodic sync adapter for whatever specific time interval you need, reading the current value from the last activity you received.

这篇关于行为识别PendingIntent站被称为在半夜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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