如何处理应用程序被HOME按钮最小化 [英] How to handle that the application is minimized by HOME button

查看:10
本文介绍了如何处理应用程序被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按钮最小化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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