问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
public static boolean checkGPSIsOpen() {
LocationManager locationManager = (LocationManager) App.getContext().getSystemService(Context.LOCATION_SERVICE);
if (locationManager == null)
return false;
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
public class App extends Application {
private static Context sContext;
@Override
public void onCreate() {
super.onCreate();
sContext = this;
}
public static Context getContext() {
return sContext;
}
}