Android 通过LocationManager获取不到当前位置

               需要在获取当前位置的时候做一下判断是否开启了允许网络定位。具体代码:

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));
    }
    

 

你可能感兴趣的:(Android 通过LocationManager获取不到当前位置)