android - why always LocationSettingsStatusCodes.SUCCESS even GPS turn off -


if(!locationmanager.isproviderenabled(locationmanager.gps_provider)) {      mgoogleapiclient = new googleapiclient         .builder(this)         .enableautomanage(this, 34992, this)         .addapi(locationservices.api)         .addconnectioncallbacks(this)         .addonconnectionfailedlistener(this)         .build();     mgoogleapiclient.connect();     locationchecker(mgoogleapiclient, this);     } 

i want see gps dialog when android gps turn off. gps turn off, status.getstatuscode() success, think error. why?

public static void locationchecker(googleapiclient mgoogleapiclient, final activity activity) {      locationrequest locationrequest = locationrequest.create();     locationrequest.setpriority(locationrequest.priority_no_power);     //locationrequest.setinterval(864 * 1000);     //locationrequest.setfastestinterval(864 * 1000);     locationsettingsrequest.builder builder = new locationsettingsrequest.builder()     .addlocationrequest(locationrequest);     builder.setalwaysshow(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:                 // location settings satisfied. client can initialize location                 // requests here.                 break;                 case locationsettingsstatuscodes.resolution_required:                 // location settings not satisfied. fixed showing user                 // dialog.                 try {                 // show dialog calling startresolutionforresult(),                 // , check result in onactivityresult().                 status.startresolutionforresult(                 activity, 1000);                 } catch (intentsender.sendintentexception e) {                 // ignore error.                 }                 break;                 case locationsettingsstatuscodes.settings_change_unavailable:                 // location settings not satisfied. however, have no way fix                 // settings won't show dialog.                 break;                 }         }     }); } 

change priority , check both gps , provider data change locationrequest.setpriority(locationrequest.priority_high_accuracy);


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -