how to know requestlocationupdates method in location manager is working or not in android emulator by using giving min. time -
here make 1 program in set time in requestlocationsupdates method 61000 miliseconds .so emulator in ddms change location lati , longi dnt press send button. after 61 seconds why not update new inserted lat long in emulator automatically after 61 seconds.
here code...
package com.getlocation; import android.content.context; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.util.log; import android.widget.textview; import com.google.android.maps.geopoint; import com.google.android.maps.mapactivity; public class showmap extends mapactivity { textview tv; /*private mapcontroller mapcontroller; private mapview mapview;*/ private locationmanager locationmanager; public void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.main); // bind layout activity tv=(textview) findviewbyid(r.id.textview1); // create map view //relativelayout linearlayout = (relativelayout) findviewbyid(r.id.mainlayout); //mapview = (mapview) findviewbyid(r.id.mapview); //mapview.setbuiltinzoomcontrols(true); //mapview.setstreetview(true); //mapcontroller = mapview.getcontroller(); //mapcontroller.setzoom(14); // zoon 1 world view locationmanager = (locationmanager) getsystemservice(context.location_service); locationmanager.requestlocationupdates(locationmanager.gps_provider, 61000, 10, new geoupdatehandler()); } @override protected boolean isroutedisplayed() { return false; } public class geoupdatehandler implements locationlistener { @override public void onlocationchanged(location location) { int lat = (int) (location.getlatitude() * 1e6); int lng = (int) (location.getlongitude() * 1e6); geopoint point = new geopoint(lat, lng); //mapcontroller.animateto(point); // //mapcontroller.setcenter(point); tv.settext(string.valueof(lat)); tv.append("\n"+string.valueof(lng)); log.d("tag", "starting update"); } @override public void onproviderdisabled(string provider) { } @override public void onproviderenabled(string provider) { } @override public void onstatuschanged(string provider, int status, bundle extras) { } } }
@saurabh emulator can not detect location automatically detect location if provide latitude , longitude , press on send button
you provide initial latitude , longitude in requestlocationupdate , setting minimum time , distance work can not understand new location without providing latitude , longitude , press send button
so best testing on device
best of luck
Comments
Post a Comment