Enable location services for Android if user chose Never option -


is there way allow location services again app (or @ least show dialog) if user chose option never?

enter image description here

i dont find way in code show again, since locationsettingsstatuscodes.settings_change_unavailable in onresult(..) callback:

    @override     public void onresult(locationsettingsresult locationsettingsresult) {         final status status = locationsettingsresult.getstatus();         switch (status.getstatuscode()) {             case locationsettingsstatuscodes.success:                 log.i(tag, "all location settings satisfied."); //                        startlocationupdates();                 break;             case locationsettingsstatuscodes.resolution_required:                 log.i(tag, "location settings not satisfied. show user dialog to" +                         "upgrade location settings ");                  try {                     // show dialog calling startresolutionforresult(), , check result                     // in onactivityresult().                     status.startresolutionforresult(activity, request_check_settings);                  } catch (intentsender.sendintentexception e) {                     log.i(tag, "pendingintent unable execute request.");                 }                 break;             case locationsettingsstatuscodes.settings_change_unavailable:                 log.i(tag, "location settings inadequate, , cannot fixed here. dialog " +                         "not created.");                 break;         }     } 

the solution found reinstall app or clear data.

i didn't find workaround enable location services if earlier user had chosen "never" option, followed @lesvmac answer's above ask user again delete , reinstall app, think isn't correct way solve problem around .

so @ present best way not allow "never" option appear in request dialog. try add

builder.setalwaysshow(true); 

to locationsettingsrequest.builder result in "yes" , "no" option instead of default "never", "yes" & "not now" & never receive settings_change_unavailable

here's full method:

 private void requestsettings() {     locationsettingsrequest.builder builder =             new locationsettingsrequest.builder()                     .setalwaysshow(true)                     .addlocationrequest(request);     pendingresult<locationsettingsresult> result =             locationservices.settingsapi.checklocationsettings(mgoogleapiclient,                     builder.build());      result.setresultcallback(this); } 

before
image_before_set_always_show

after

image_after_set_always_show


Comments