需要在获取当前位置的时候做一下判断是否开启了允许网络定位。具体代码:
LocationManager mManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
if(!mManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
Toast.makeText(this, "请打开使用GPS和使用网络定位以提高精度",Toast.LENGTH_LONG).show();
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}