Changing Location Settings - Android Tutorial -


i trying implement code request change location settings. following android studio tutoriel so.

however, when followed tutorial , put code inside actual studio, saw came several errors.

protected void createlocationrequest() {         locationrequest mlocationrequest = new locationrequest();         mlocationrequest.setinterval(10000);         mlocationrequest.setfastestinterval(5000);         mlocationrequest.setpriority(locationrequest.priority_high_accuracy);         locationsettingsrequest.builder lsbuilder = new locationsettingsrequest.builder();         lsbuilder.addlocationrequest(mlocationrequest);         final pendingresult<locationsettingsresult> result = locationservices.settingsapi.checklocationsettings(mgoogleapiclient,lsbuilder.build());         result.setresultcallback(new resultcallback<locationsettingsresult>() {             @override             public void onresult(locationsettingsresult result) {                 final status status = result.getstatus();                 final locationsettingsstates = 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, can fixed                         // showing user dialog.                         try {                             // show dialog calling startresolutionforresult(),                             // , check result in onactivityresult().                             status.startresolutionforresult(                                     mainactivity.this,                                     request_check_settings);                         } catch (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;                 }             }         }); 

firstly,

final locationsettingsstates = result.getlocationsettingsstates(); 

comes error of unexpected token. not quite sure what's wrong here. there seem additional information. secondly,

status.startresolutionforresult(mainactivity.this,request_check_settings); 

in there, request_check_settings undefined. not quite sure should define or anything.

can explain above 2 errors?

locationsettingsstates type, need specify store object of type. replace:

final locationsettingsstates = result.getlocationsettingsstates(); 

with:

final locationsettingsstates states = result.getlocationsettingsstates(); 

i believe request_check_settings unique identifier set callback, declare in class as:

private final int request_check_settings = 0; // unique identifier 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -