关闭GPS图标时,LocationListener的是睡觉 [英] Turn off GPS icon when LocationListener is sleeping

查看:340
本文介绍了关闭GPS图标时,LocationListener的是睡觉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎了一下,在Android上LocationListener的。我想打一个应用程序,将得到当前GPS位置,然后后来睡了很长时间。一天或更长时间。在这一段时间里,我想了GPS通知图标不显示。

I am struggling a bit with the LocationListener in Android. I want to make an app that will get the current GPS location, and then afterwards sleep for a long time. A day or more. In this period of time i want the GPS notification icon to not show.

我现在有什么,是在onLocationChanged一个视频下载(x),但是这将继续处于休眠期的图标。我怎样才能做到这一点,有没有更好的方法,而不是使用视频下载?

What i have now, is in the onLocationChanged a Thread.sleep(x) but this will keep the icon on in the sleep period. How can i do this, and is there a better approach than to use Thread.sleep?

在此先感谢

推荐答案

嘿安德烈亚斯! 你必须关闭LocationManager完全地为。我做到了我的应用程序,在这里我只能每10秒检查位置,因为我发现,该关闭可以节省比LocationManager的MIN_DISTANCE或MIN_TIME一点更多的电能。

Hey Andreas! You have to turn off the LocationManager completly for that. I did it in my App, where I only check the Location every 10 seconds, 'cause I found out, that the turning off saves a bit more battery power than a min_distance or min_time of the LocationManager.

是这样的:

// Turning off
mLocationManager.removeUpdates(gpsListener);
mLocationManager = null;

// Turning on again
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);            
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_MINTIME, GPS_MINDISTANCE, gpsListener);

图标将消失,直到LocationManager再次打开。

The icon will disappear till the LocationManager is turned on again.

这篇关于关闭GPS图标时,LocationListener的是睡觉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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