Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.2 kB
3
Indexable
Never
protected void acceptLocation() {

        Hawk.put("show_dialog_permission", false);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

            if (hasForegroundLocationPermission()) {

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                    if(hasBackgroundLocationPermission()){
                        startMonitoringLocation();
                    }else{
                        // TODO EXIBIR TELA INFORMANDO QUE PRECISAMOS
                        //  DA LOCALIZACAO EM BACKGROUND POR X MOTIVO
                        ActivityCompat.requestPermissions(this,
                                new String[]{Manifest.permission.ACCESS_BACKGROUND_LOCATION},
                                START_MONITORING_LOCATION);
                    }
                }else{
                    startMonitoringLocation();
                }
            }else{
                ActivityCompat.requestPermissions(this,
                        new String[]{
                                Manifest.permission.ACCESS_FINE_LOCATION}, START_MONITORING_LOCATION);
            }
        } else {
            startMonitoringLocation();
        }
    }