Android Maps Get Longitude and Latitude -


i trying location longitude , latitude appear in toast on updates. however, nothing appears ! map loading fine, cannot coordinates in toast. hints?

  package com.parse.starter;    import android.app.activity;   import android.location.location;   import android.location.locationlistener;   import android.os.bundle;   import android.util.log;   import android.widget.textview;   import android.widget.toast;    import com.google.android.gms.common.connectionresult;   import com.google.android.gms.common.api.googleapiclient;   import com.google.android.gms.location.locationrequest;   import com.google.android.gms.location.locationservices;   import com.google.android.gms.maps.cameraupdatefactory;   import com.google.android.gms.maps.googlemap;   import com.google.android.gms.maps.mapfragment;   import com.google.android.gms.maps.onmapreadycallback;   import com.google.android.gms.maps.model.latlng;   import com.google.android.gms.maps.model.markeroptions;   import com.parse.parseanalytics;   import com.parse.parseobject;    public class parsestarterprojectactivity extends activity implements onmapreadycallback,     googleapiclient.connectioncallbacks, googleapiclient.onconnectionfailedlistener, locationlistener { /** called when activity first created. */  /**  * provides entry point google play services.  */ public static final long update_interval_in_milliseconds = 20000;  /**  * fastest rate active location updates. exact. updates never more frequent  * value.  */ public static final long fastest_update_interval_in_milliseconds =         update_interval_in_milliseconds / 2;  // keys storing activity state in bundle. protected final static string requesting_location_updates_key = "requesting-location-updates-key"; protected final static string location_key = "location-key"; protected final static string last_updated_time_string_key = "last-updated-time-string-key"; protected googleapiclient mgoogleapiclient;  /**  * stores parameters requests fusedlocationproviderapi.  */ protected locationrequest mlocationrequest;  /**  * represents geographical location.  */ protected location mcurrentlocation;  /**  * tracks status of location updates request. value changes when user presses  * start updates , stop updates buttons.  */ protected boolean mrequestinglocationupdates;  /**  * time when location updated represented string.  */ protected string mlastupdatetime;  public void oncreate(bundle savedinstancestate) {     log.d("message: ", "1");      super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      parseanalytics.trackappopenedinbackground(getintent());     log.d("message: ", "made far");      try {          mapfragment mapfragment = (mapfragment) getfragmentmanager()                 .findfragmentbyid(r.id.map);         mapfragment.getmapasync(this);      } catch (exception exc) {     log.d("error:", exc.getmessage().tostring());     }      buildgoogleapiclient(); }  @override public void onmapready(googlemap map) {     latlng sydney = new latlng(-33.867, 151.206);      map.setmylocationenabled(true);     map.movecamera(cameraupdatefactory.newlatlngzoom(sydney, 13));      map.addmarker(new markeroptions()             .title("sydney")             .snippet("the populous city in australia.")             .position(sydney));     map.setmylocationenabled(true); }  protected synchronized void buildgoogleapiclient() {     toast.maketext(this,"buildgoogleapiclient",             toast.length_short).show();     mgoogleapiclient = new googleapiclient.builder(this)             .addconnectioncallbacks(this)             .addonconnectionfailedlistener(this)             .addapi(locationservices.api)             .build();     createlocationrequest(); } @override public void onconnected(bundle bundle) {     toast.maketext(this,"onconnected",             toast.length_short).show();     if (mrequestinglocationupdates) {         startlocationupdates();     } }  protected void startlocationupdates() {     locationservices.fusedlocationapi.requestlocationupdates(             mgoogleapiclient, mlocationrequest, (com.google.android.gms.location.locationlistener) this);     toast.maketext(this,"startlocationupdates",             toast.length_short).show(); }  @override public void onconnectionsuspended(int i) {  }  @override public void onconnectionfailed(connectionresult connectionresult) {  }  protected void createlocationrequest() {     locationrequest mlocationrequest = new locationrequest();     mlocationrequest.setinterval(10000);     mlocationrequest.setfastestinterval(5000);     mlocationrequest.setpriority(locationrequest.priority_high_accuracy); }  @override public void onlocationchanged(location location) {     // mcurrentlocation = location;    // location.     mcurrentlocation=location;     textview txt = (textview) findviewbyid(r.id.longlat);     toast.maketext(this,location.getlongitude() + " " + location.getlatitude() ,             toast.length_short).show();     toast.maketext(this,"onlocationchanged",             toast.length_short).show();     log.i("longitude / latitude", location.getlongitude() + " " + location.getlatitude());     parseobject slocation = new parseobject("location");     slocation.put("longitude", location.getlongitude());     slocation.put("latitude", location.getlatitude());     slocation.put("altitude", location.getaltitude());     slocation.put("accuracy", location.getaccuracy());     slocation.saveinbackground(); }   @override public void onstatuschanged(string provider, int status, bundle extras) {  }  @override public void onproviderenabled(string provider) {  }  @override public void onproviderdisabled(string provider) {  } } 


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -