关闭GPS编程GPS

2023-09-07 11:45:16 作者:不忘初心方得始终

我有什么:目前我的应用程序是通过GPS提供的位置

What i have: Currently my app is giving location through gps.

我想要什么: GPS来我从应用程序退出后自动关闭。因为它不断告诉我的位置,一次又一次,看起来奇怪的,也是全球定位系统消耗了大量的电池。

what i want: Gps to turn off automatically after i exit from the application. Because it keeps on telling me the location time and again that looks odd and also gps consume a lot battery.

请帮我在这方面的工作。 在此先感谢!

Kindly help me in this regard. Thanks in advance!

推荐答案

综观上述评论跟帖,似乎它可以关闭GPS编程(但看到只有12 Upvotes)

Looking at above comment thread it seems its possible to turn OFF GPS programatically (But seeing only 12 Upvotes)

但是如果你从你的应用程序切换关闭GPS编程,如果其他应用程序使用的GPS服务?

在的解决方案的会像

The solution would be like

打开设置的机器人,然后告诉用户关闭GPS,当他从应用程序退出...

Open Settings of android and then tell user to turn OFF GPS when he exits from the application...

有关这一点,你可以这样做:

For this you can do like :

Intent i = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(i);

您可以尝试像

locationManager.removeUpdates(myLocationListener); 
locationManager = null;

该关闭GPS进行这个程序,但它仍然可以通过其他应用程序使用。

This shutdown gps for this app, but its still available for use by other apps.

 
精彩推荐
图片推荐