java - When Getting GPS Location, load another URL -
i have little problem... have made android application extends webview. webview html page map on this: map example, here got inspiration. oncreate method looks this:
super.oncreate(savedinstancestate);           //removes title bar in application          requestwindowfeature(window.feature_no_title);          setcontentview(r.layout.main);           //creation of webview found in xml layout file          browserview = (webview)findviewbyid(r.id.webkit);           //removes both vertical , horizontal scroll bars           browserview.setverticalscrollbarenabled(false);          browserview.sethorizontalscrollbarenabled(false);            mylocationmanager=(locationmanager)getsystemservice(context.location_service);          //enable javascripts           url = "http://www.my-homepage.dk/map_example.html";           browserview.getsettings().setjavascriptenabled(true);            //the website wrapped webview           browserview.loadurl(url);   so when application gets gps location, invokes method:
locationlistener onlocationchange=new locationlistener() {     public void onlocationchanged(location location) {    stringbuilder buf=new stringbuilder(url);   buf.append("?");  buf.append("lon=");  buf.append(string.valueof(location.getlongitude()));  buf.append("&");  buf.append("lat=");  buf.append(string.valueof(location.getlatitude()));      browserview.loadurl(buf.tostring());   }   so loads url.... but, problem is, 1. keeps orignal website "map image", imagined "unload" page, , 2. when second url loaded, takes quite long time before finished, , when testing on htc desire, doesnt show second loaded page (the map location) before turns screen off , lock, or if go out , in application, helps too...
hope can :)
a suggestion - in onlocationchanged, make locationfound(); first statement instead of last.
it stop listener immediately, loadurl statement take time complete, while provider sending more updates.
Comments
Post a Comment