geolocation - My current location in android -


i'm new , has taken lots of time trying figure out. have code below seems not working , crashes. know might little thing holding need fixed , running.

can in correcting please want learn well.

import com.google.android.maps.geopoint; import com.google.android.maps.mapactivity; import com.google.android.maps.mapcontroller; import com.google.android.maps.mapview;  import android.content.context; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.view.menu; import android.view.menuitem;  public class mainactivity extends mapactivity {      protected static final geopoint geopoint = null;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          mapview view = (mapview) findviewbyid(r.id.mapview);         view.setbuiltinzoomcontrols(true);          final mapcontroller control = view.getcontroller();          locationmanager manager = (locationmanager) this.getsystemservice(context.location_service);         locationlistener listener = null;         manager.requestlocationupdates(locationmanager.gps_provider, 0, 0, listener);         //control.setcenter(new geopoint((int)((locationmanager) manager).getlatitude(), (int)((locationmanager) manager).getlongitude()));      }  @override         protected boolean isroutedisplayed() {             return false;         } 

can't guarantee it's issue, one, pass null locationlistener locationmanager.

you have instantiate listener. otherwise won't listen anything. along lines of this:

locationlistener listener = new locationlistener(){         @override         public void onstatuschanged(string provider, int status, bundle extras) {         }          @override         public void onproviderenabled(string provider) {         }          @override         public void onproviderdisabled(string provider) {         }          @override         public void onlocationchanged(location location) {             // can newest location         }     }; 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -