android - Problems using Smart Location Library -


i trying use smart location library obtain periodic location updates. when start process fires listener once there no further updates. here code used

public void starttracking(view v)    {     provider = new locationgoogleplayserviceswithfallbackprovider(this);       log.i("tag","start tracking");     smartlocation smartlocation = new smartlocation.builder(this)             .logging(true)             .build();      smartlocation.location(provider)             .config(locationparams.best_effort)             .start(this);     smartlocation.activity().start(this); }  public void stoptracking(view v) {     log.i("tag","stop tracking");     smartlocation.with(this).location().stop();     smartlocation.with(this).activity().stop();  }  @override public void onactivityupdated(detectedactivity detectedactivity) {     log.i("tag","activityupdate : "+detectedactivity.tostring()); }  @override public void onlocationupdated(location location) {     log.i("tag","locationupdate : "+location.getlatitude()+","+location.getlongitude()); } 

this logcat output got

 01-27 14:09:01.791 3038-3038/com.angulusits.smartlocationtest i/tag:  start tracking    01-27 14:09:01.879 3038-3038/com.angulusits.smartlocationtest i/tag:  activityupdate : detectedactivity [type=still, confidence=100]    01-27 14:09:02.017 3038-3038/com.angulusits.smartlocationtest i/tag:  locationupdate : <some-value>,<some-value> 

this given press startbutton, no more values.

i checked code on library best_effort value :

public static final locationparams best_effort = new builder().setaccuracy(locationaccuracy.medium).setdistance(150).setinterval(2500).build(); 

so expected updates every 2500 millisecs if device not moving. appreciate if can point me in right direction.

you need continuous() while creating location listener. try code snippet below,

private void startlocationlistener() {      long mloctrackinginterval = 1000 * 5; // 5 sec     float trackingdistance = 0;     locationaccuracy trackingaccuracy = locationaccuracy.high;      locationparams.builder builder = new locationparams.builder()             .setaccuracy(trackingaccuracy)             .setdistance(trackingdistance)             .setinterval(mloctrackinginterval);      smartlocation.with(this)             .location()             .continuous()             .config(builder.build())             .start(new onlocationupdatedlistener() {                 @override                 public void onlocationupdated(location location) {                     processlocation(location);                 }             }); } 

its late reply! anyway someone.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -