开启或关闭状态的Andr​​oid GPS状态、Andr、GPS、oid

2023-09-06 04:03:31 作者:恍惚间、我们慢慢老了

有没有什么办法来检查Android的GPS是没有任何许可或关闭,只是状态我不需要切换。

Is there any way to check if the Android GPS is on or off without any permission, just the state I don't need to toggle it.

感谢

推荐答案

没有。检查GPS状态在Android上要求

No. Checking GPS Status on Android requires

android.permission.ACCESS_FINE_LOCATION

在code,检查GPS状态

The code to check the status of GPS


 LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE );
 boolean statusOfGPS = manager.isProviderEnabled(LocationManager.GPS_PROVIDER);