How to handle that the application is minimized by HOME button(如何处理应用程序被HOME按钮最小化)
问题描述
几天前出现了一个问题.我有一个监听 GPS 位置的应用程序.监听器是一个一直工作的后台服务,该服务将数据保存在应用程序级别,每个活动都会读取这些数据.因此,当我按下后退按钮时,我能够捕捉到此事件并且我可以停止服务,但是当我按下 HOME 按钮时,服务仍在工作,尽管应用程序处于后台模式并且这会消耗电池,因为 GPS 始终工作.我该如何处理这个事件?我确实想在用户按下 HOME 按钮时停止所有服务,并在用户回来时再次启动它们.10 倍
An issue has appeared a few days ago. I have an application that listen for GPS location. The listener is a background service that works all the time, this service saves data in application level and each activity reads this data. So, when i press back button i am able to catch this event and i can stop the service, but when i press HOME button the service is still working although the application is in background mode and this consumes battery, because the GPS always works. How can i handle this event? I do want to stop all services when the user presses HOME button and start them again when user gets back. 10x
推荐答案
您无法在 Android 应用程序中处理主页按钮事件.Google 已将其仅供内部使用.
You can not handle home button events in your Android application. Google has made it for internal use only.
LINK 1链接2
这篇关于如何处理应用程序被HOME按钮最小化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何处理应用程序被HOME按钮最小化
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
