android - How to show enable location dialog like Google maps? -


i use latest version of google play services (7.0) , followed steps given in guide , enabled location dialog below, has "never" button. app mandatorily needs location don't want show never user, because once user clicks "never", i'm unable location or request location again @ all.

where google maps has yes , no button without never button, idea how achieve same?

my app's image enter image description here

google map's image enter image description here

locationsettingsrequest.builder has method setalwaysshow(boolean show). while document indicates it's doing nothing(updated 2015-07-05: updated google documentation has removed wording), setting builder.setalwaysshow(true); enable google maps behavior: enter image description here

here's code got working:

    if (googleapiclient == null) {         googleapiclient = new googleapiclient.builder(getactivity())                 .addapi(locationservices.api)                 .addconnectioncallbacks(this)                 .addonconnectionfailedlistener(this).build();             googleapiclient.connect();              locationrequest locationrequest = locationrequest.create();             locationrequest.setpriority(locationrequest.priority_high_accuracy);             locationrequest.setinterval(30 * 1000);             locationrequest.setfastestinterval(5 * 1000);             locationsettingsrequest.builder builder = new locationsettingsrequest.builder()                     .addlocationrequest(locationrequest);              //**************************             builder.setalwaysshow(true); //this key ingredient             //**************************              pendingresult<locationsettingsresult> result =                     locationservices.settingsapi.checklocationsettings(googleapiclient, 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(                                         getactivity(), 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;                     }                 }             });             } 

from android documentation


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -