java - Android emulator, Finding mock user location coordinates. Having problems -
hey guys, i'm having trouble trying find user's longitude , location run program , set telnet command geo fix mock location. while emulator running, set mock coordinates emulator become unresponsive , have program fail in detecting input coordinates.
import android.app.activity; import android.content.context; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.location.locationprovider; import android.os.bundle; import android.widget.textview; import android.widget.toast; public class lbsact extends activity{ /** called when activity first created. */ public double longitude; public double latitude; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); longitude = 0; latitude = 0; //creating listener , manager locationmanager lmanager = (locationmanager) this.getsystemservice(context.location_service); locationlistener createlisten = new locationlistener(){ @override public void onlocationchanged(location location) { //longitude = location.getlongitude(); //latitude = location.getlatitude(); string printout1 = "my current location is: " + "latitude = " + location.getlatitude() + "longitude = " + location.getlongitude(); toast.maketext(getapplicationcontext(),printout1,toast.length_long).show(); } @override public void onproviderdisabled(string provider) { toast.maketext(getapplicationcontext(), "gps disabled", toast.length_long).show(); } @override public void onproviderenabled(string provider) { toast.maketext(getapplicationcontext(), "gps enabled", toast.length_long).show(); } @override public void onstatuschanged(string provider, int status, bundle extras) { } }; //cant use network emulator, can use gps mock locations //toast.maketext(getapplicationcontext(), "does work?", toast.length_long).show(); lmanager.requestlocationupdates( locationmanager.gps_provider, 0, 0, createlisten); } }
first of all. i'm assuming have read following: http://developer.android.com/guide/topics/location/obtaining-user-location.html
since mentioned injecting mock location data. there couple other things try to, instance use kml file inject gps locations: http://developer.android.com/guide/developing/tools/ddms.html#emulator-control
but main thing should create logging messages can more accurately detect program failing. here's article on how setup logcat: http://www.droidnova.com/debugging-in-android-using-eclipse,541.html
i suggest sending text screen might not work application can crash before gets calls.
also, have tried debugging application through eclipse? break on crash , give location of app failing.
i'll update answer give more details on issue it's kind of hard see what's happening without stack trace or logging trace.
Comments
Post a Comment