android - Unable to get location using LocationRequest or getLastLocation() -


i've been working on quite time. i've tried can think of.

i'm trying rough location (coarse location). first try following:

googleapiclient = new googleapiclient.builder(this)             .enableautomanage(this, 0 /* clientid */, this)             .addapi(places.geo_data_api)             .addapi(locationservices.api)             .build();  googleapiclient.connect(); 

and this:

@override public void onconnected(bundle bundle) {     lastknownlocation = locationservices.fusedlocationapi.getlastlocation(googleapiclient);      if(lastknownlocation == null)     {         locationservices.fusedlocationapi.requestlocationupdates(googleapiclient, locationrequest, this);     }     else     {         movemap();     } } 

this returns null. totally possible, no worries. however, after this, tried request location updates using locationrequest, follows:

locationrequest = new locationrequest();     locationrequest.setinterval(10000);     locationrequest.setfastestinterval(5000);     locationrequest.setpriority(locationrequest.priority_low_power); 

and this:

@override public void onlocationchanged(location location) {     lastknownlocation = location;     locationservices.fusedlocationapi.removelocationupdates(googleapiclient, this);     movemap(); } 

both of these methods don't give me sort of location. that's possible well, downloaded fake gps app, set location mode gps in phone settings, , set fake location.

when run app after doing this, still fails find location. i've tried with:

locationrequest.setpriority(locationrequest.priority_balanced_power_accuracy) locationrequest.setpriority(locationrequest.priority_high_accuracy) 

nothing seems work. permissions in manifest. doing wrong?

have done start getting location updates ?

locationservices.fusedlocationapi.requestlocationupdates(              mgoogleapiclient, mlocationrequest, this); 

please check answer.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -