首页 > 解决方案 > 地图应在接受许可时更新谷歌地图上的位置,但它会崩溃而不是更新

问题描述

private boolean isGPSenable() {
        LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
        boolean providerEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if (providerEnable) {
            return true;

        } else {

            AlertDialog alertDialog = new AlertDialog.Builder(this).setTitle("GPS permission")
                    .setMessage("GPS is required for this app to work. Please enable GPS")
                    .setPositiveButton("yes", ((dialog, which) -> {
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivityForResult(intent, GPS_REQUEST_CODE);


                    })).setCancelable(false).show();


        }
        return false;
    }

标签: androidlocationmapsandroid-permissions

解决方案


推荐阅读