Firebase监听器对电池寿命和CPU的影响 [英] Firebase listener effect on battery life and CPU

查看:258
本文介绍了Firebase监听器对电池寿命和CPU的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想在Firebase中的服务中从Firebase中进行监听(如果已将孩子添加到已签名的用户朋友的请求中),是否会影响电池电量?还是用户的CPU?是的,我应该考虑寻找其他解决方案吗?我计划在后台也有3个其他的听众.谢谢.

If I want to have a service in my android app that listens from Firebase if a child has been added to the signed user friend's request, does it affect the battery or the CPU of the users? I yes, should I consider finding another solution? I plan to have 3 other listeners in the background as well. Thanks.

推荐答案

您应该避免这种模式,因为:

This is a pattern you should avoid because:

1)在较新版本的Android中,设备可能会以打ze模式从您的Android应用断开网络连接.如果您想随时收到任何更改的通知,则此操作将无效.

1) The device may disconnect the network from your Android app in doze mode in newer versions of Android. If you're trying to get notified at any time of any change, this is not going to work.

2)Firebase Cloud Messaging是可靠地唤醒设备以处理您的应用程序需要了解的更改的更好方法.

2) Firebase Cloud Messaging is a better way to reliably wake a device to handle a change that your app needs to know about.

Firebase实时数据库使用websocket来让客户端知道事情何时发生变化.至少从打开的插座中消耗的电池

Firebase Realtime Database uses a websocket to let a client know when things change. At least the drain on battery from an open socket is not a big deal. You just shouldn't count on that connection unless your app is visible and has a reliable network connection.

这篇关于Firebase监听器对电池寿命和CPU的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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