android - LocationServices.SettingsApi Reset SETTINGS_CHANGE_UNAVAILABLE flag -


updating google play services v7.0+, , based in this sample locationupdates in android, have following code connect locationservices.settingsapi , check if user has ok application receive location updates.

    locationsettingsrequest.builder builder = new locationsettingsrequest.builder();     builder.addlocationrequest(mlocationrequest);     mlocationsettingsrequest = builder.build();      pendingresult<locationsettingsresult> result =             locationservices.settingsapi.checklocationsettings(                     mlocationclient,                     mlocationsettingsrequest             );     result.setresultcallback(this); 

where this following callback:

    @override     public void onresult(locationsettingsresult locationsettingsresult) {          final status status = locationsettingsresult.getstatus();         intent resolutionintent;         switch (status.getstatuscode()) {             case locationsettingsstatuscodes.success:                 // ok, starting request location updates                 break;             case locationsettingsstatuscodes.resolution_required:                 // seems user need change setting enable locations updates, call startresolutionforresult(activity, request_code)                 break;             case locationsettingsstatuscodes.settings_change_unavailable:                 // error, cannot retrieve location updates.                 break;         }     } 

the success ok reproduce, keep gps enabled.

the resolution_required ok reproduce, disable gps.

the settings_change_unavailable deal: if user select "never" when step resolution_required executed, result come status always.

did google play services has option reset programmatically flag when user select "never" option?

i know "never" seems "really, don't ask me again!!!", thinking create option in case user change mind, of course, if can possible.

in case i'll able receive status resolution_required again , ask user accept locationupdates when app executed next time.

locationsettingsrequest.builder has method setalwaysshow changes buttons of dialog:

always show dialog, without "never" option suppress future dialogs app. when flag set true, dialog show if location settings not satisfy request, if user has chosen "never". note: use method if dialog result of explicit user-initiated action requires location proceed. canceling dialog should cancel initiated action.

instead default yes, not now , never buttons if call setalwaysshow(true); have yes , no, user won't choose never , never receive settings_change_unavailable

locationsettingsrequest.builder builder = new locationsettingsrequest.builder(); builder.addlocationrequest(mlocationrequest); builder.setalwaysshow(true);  mlocationsettingsrequest = builder.build();  pendingresult<locationsettingsresult> result =         locationservices.settingsapi.checklocationsettings(                 mlocationclient,                 mlocationsettingsrequest         );  result.setresultcallback(this); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -