退出程序时以编程方式关闭 GPS方式、程序、GPS

2023-09-07 04:37:25 作者:呐谁っ伱不懂

我已经通过编程方式启动了我的 GPS意图 myIntent = 新意图(Settings.ACTION_SECURITY_SETTINGS);mContext.startActivity(myIntent);

I have started my GPS programmatically by Intent myIntent = new intent(Settings.ACTION_SECURITY_SETTINGS); mContext.startActivity(myIntent);

退出程序时如何关闭 GPS...

How i will turn Off GPS when i exit from my program...

推荐答案

试试这个:

locationManager.removeUpdates(myLocationListener);
locationManager = null;

这将关闭此应用的 GPS,但仍可供其他应用使用.

This will shut down GPS for this app, but it is still available for use by other apps.

请务必在真机上测试您的应用,因为模拟器显示的 GPS 行为与真机不同.

Be sure to test your app on a real phone because the emulator does not show the same GPS behavior as a real phone.