Android 应用程序 24/7 在后台运行并尽可能减少电池消耗
我想创建 Android 应用程序,当我在我的 wifi 区域时,当“MyWifi”无法到达时,它会立即使用 wifi,应该更改并通过 3g/4g 启动数据连接...所以我的问题是如何制作该应用程序运行 24/7 并消耗尽可能少的电池,如果有人可以给我一些关于 wifi 和数据连接的系统调用是什么,或者向我推荐任何教程和示例,认为我会发现它们很方便< 谢谢
I want to create android app that while i am in my wifi area it will use the wifi soon as "MyWifi" is not in reach should change and start data connection through 3g/4g...so my question is how to make the application to run 24/7 and drain less as possible battery, also if anyone can givme something about wifi and data connection what are the system calls, or refer me to any tutorials od examples that think that i will find them handy<
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不会想让您的应用程序全天候(24/7)“运行”,因为这会导致设备永远不会进入睡眠状态,从而以通常不可接受的方式耗尽电池电量。
您可以轻松捕获 WiFi 连接状态变化的广播。
例如,您可以查看此处
如果您希望您的应用程序 24/7 运行,是为了对某些事件做出反应吗?因为您通常可以使用广播接收器或意图捕获任何事件。在大多数情况下,这是要走的路。
You will not want to let your app "run" 24/7, because that will cause the device to never go to sleep and therefore drain the battery in a way that is usually not acceptable.
You can easily catch an broadcast of the state change of your wifi connection.
For an example you can look here
If you want your app to be running 24/7, is it to react to some events? Because you can usually catch any event with BroadCast-Receivers or Intents. In most scenarios this is the way to go.