gps - LocationListener Android -


i following guide on android developer retrieve location , trying speed it. have written code following guide log doesnt print , text doesnt update.

        final button button = (button) findviewbyid(r.id.button3);        final textview speed = (textview) findviewbyid(r.id.textview5);  // acquire reference system location manager         final locationmanager locationmanager = (locationmanager) this.getsystemservice(context.location_service);         final string locationprovider = locationmanager.gps_provider; // define listener responds location updates         final locationlistener locationlistener = new locationlistener() {             public void onlocationchanged(location location) {                 // called when new location found network location provider.                 float gets=(location.getspeed());                 speed.settext("speed: "+gets);             }              public void onstatuschanged(string provider, int status, bundle extras) {                  log.e("",""+status+" "+provider);             }              public void onproviderenabled(string provider) {              }              public void onproviderdisabled(string provider) {}         };           button.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 if (running == 0) {                     running = 1;                     button.settext("stop measuring");                     locationmanager.requestlocationupdates(locationprovider, 0, 0, locationlistener);                  } else {                     running = 0;                     button.settext("start measuring");                     locationmanager.removeupdates(locationlistener);                 }             }         }); 

no problem seems in code. getting location using gps_provoder. there may problem getting location gps.you should first verify whether gps working on device or not. can using google map application , check location on moving device.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -