0

i'm using dialog from Location.Settings.Request and work it well in pre-lollipop, but in lollipop the wifi never starts only gps and bluetooth starts.

more detail:

when i choose yes button only gps y bluetooth starts, but the second time that call method detects wifi,gps,bletooth are active , and only gps y bluetooth but never wifi.

please help me i really i need implement in lollipop.

this is my method to show dialog:

This is my method to show dialog:

    public void ActivarWifiGps(boolean gpsrequerido){
            mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
                    .build();
         mGoogleApiClient.connect();
           mLocationRequest.setInterval(1000);
          mLocationRequest.setFastestInterval(FATEST_INTERVAL);
            mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
            mLocationRequest.setSmallestDisplacement(10);

            builder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest);
            builder.setAlwaysShow(true);


            builder.setNeedBle(true);
            PendingResult<LocationSettingsResult> result =
                    LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());

            result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
                @Override
                public void onResult(LocationSettingsResult result) {
                    final Status status = result.getStatus();
                    final LocationSettingsStates state = result.getLocationSettingsStates();
                    switch (status.getStatusCode()) {
                        case LocationSettingsStatusCodes.SUCCESS:
                            // All location settings are satisfied. The client can initialize location
                            // requests here.
                            //...

        //ENTER HERE THE SECOND TIME BUT WIFI IS FALSE BECAUSE WIFI STILL NO STARTS..

                            break;
                        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                            // Location settings are not satisfied. But could be fixed by showing the user


                            Toast.makeText(MainActivity.this, "Show dialog", Toast.LENGTH_SHORT).show();
                            try {
                                // Show the dialog by calling startResolutionForResult(),
                                // and check the result in onActivityResult().
                                status.startResolutionForResult(
                                        MainActivity.this,
                                        REQUEST_CHECK_SETTINGS);
                            } catch (IntentSender.SendIntentException e) {
                                // Ignore the error.
                            }
                            // }
                            break;
                        case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:

                            // Location settings are not satisfied. However, we have no way to fix the
                            // settings so we won't show the dialog.
                            //...
                            break;
                    }
                }
            });
        }
kcire_eae
  • 333
  • 1
  • 3
  • 10
  • did you ask for location permission? – Deividi Cavarzan Dec 20 '15 at 00:29
  • yes, but i found that even google maps it's not working properly – kcire_eae Dec 21 '15 at 18:35
  • 1
    Please refer to the solution that i had answered here: http://stackoverflow.com/questions/33969085/how-to-give-option-for-enable-gps/34028605#34028605 also dont forget to compare your code with the repo here: https://github.com/googlemaps/android-samples/tree/master/ApiDemos/app/src/main/java/com/example/mapdemo – bjiang Dec 21 '15 at 19:44

0 Answers0