google play services - Android new LocationSettings and Geofencing -


i'm trying since 7 days no results. problem resultcallback, geofencing need resultcallback while locationsettings need resultcallback, there way this? appreciate tips... i'm using latest google play services 7.0 support :)

public class geofenceintentservice         extends intentservice         implements googleapiclient.connectioncallbacks,                   googleapiclient.onconnectionfailedlistener,                    resultcallback<status>, resultcallback<locationsettingsresult> {      // onresult geofencing     public void onresult(status status) {         log.i(tag, "onresult");         if (status.issuccess()) {             log.i(tag, "status.issuccess()");         } else {           string errormessage = geofenceerrormessages.geterrorstring(getapplicationcontext(),                 status.getstatuscode());           log.e(tag, errormessage);         }     }      // onresult locationsettings     @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(baseactivity.this, 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;         }     }      @override     protected void onactivityresult(int requestcode, int resultcode, intent data) {         switch (requestcode) {             // check integer request code supplied startresolutionforresult().             case request_check_settings:                 switch (resultcode) {                     case activity.result_ok:                         log.i(tag, "user agreed make required location settings changes.");                         startlocationupdates();                         break;                     case activity.result_canceled:                         log.i(tag, "user chose not make required location settings changes.");                         break;                 }                 break;         }     } } 

i had same problem , did

class definition:

public class activity/service extends appcompatactivity/intentservice implements         connectioncallbacks,          onconnectionfailedlistener,         resultcallback<status> {    ... } 

for geofencingapi:

public void addgeofencesbuttonhandler(view view) {     if (!mgoogleapiclient.isconnected()) {         // log.e(tag, "not connected");         return;     }      try {         pendingresult<status> result =                 locationservices.geofencingapi.addgeofences(                         mgoogleapiclient,                         getgeofencingrequest(),                         getgeofencependingintent()                 );          result.setresultcallback(this);      } catch (securityexception securityexception) {         logsecurityexception(securityexception);     } } 

for settingsapi:

used chaining setresultcallback

protected void checklocationsettings() {             locationservices.settingsapi.checklocationsettings(                     mgoogleapiclient,                     mlocationsettingsrequest             ).setresultcallback(new resultcallback<locationsettingsresult>() {                 @override                 public void onresult(locationsettingsresult locationsettingsresult) {                     final status status = locationsettingsresult.getstatus();                     switch (status.getstatuscode()) {                         case locationsettingsstatuscodes.success:                             log.i(tag, "all location settings satisfied.");                             if (!mrequestinglocationupdates) {                                 mrequestinglocationupdates = true;                                 setbuttonsenabledstate();                                 startlocationupdates();                             }                             break;                         case locationsettingsstatuscodes.resolution_required:                             log.i(tag, "location settings not satisfied. show user dialog to" +                                     "upgrade location settings ");                             try {                                 status.startresolutionforresult(mainactivity.this, 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;                     }                 }             }); } 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -