geocoding in android map -
hi..i doing geocoding in android map.(i.e)getting address input user & locate particular point using marker.how this?
my code
simplegooglemaps.java
public class simplegooglemaps extends mapactivity { geocoder geocoder=null; mapview mapview=null; @override protected boolean islocationdisplayed(){ return false; } @override protected boolean isroutedisplayed(){ return false; } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mapview=(mapview)findviewbyid(r.id.map); mapview.setbuiltinzoomcontrols(true); button geobtn=(button)findviewbyid(r.id.geocodebtn); geocoder=new geocoder(this); geobtn.setonclicklistener(new onclicklistener(){ @override public void onclick(view srg0){ try{ edittext loc=(edittext)findviewbyid(r.id.location); string locationname=loc.gettext().tostring(); list<address>addresslist=geocoder.getfromlocationname(locationname,5); if(addresslist!=null && addresslist.size()>0) { int lat=(int)(addresslist.get(0).getlatitude()*1000000); int lng=(int)(addresslist.get(0).getlongitude()*1000000); geopoint pt=new geopoint(lat,lng); mapview.getcontroller().setzoom(15); mapview.getcontroller().setcenter(pt); } }catch(ioexception e){ e.printstacktrace(); } }}); } }
xml file is
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:layout_width="fill_parent" android:layout_alignparentbottom="true" android:layout_height="wrap_content" android:orientation="vertical"> <edittext android:layout_width="fill_parent" android:id="@+id/location" android:layout_height="wrap_content" /> <button android:id="@+id/geocodebtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="find"/> </linearlayout> <com.google.android.maps.mapview android:id="@+id/map" android:clickable="true" android:layout_width="fill_parent" android:layout_height="320px" android:apikey= "0jfvbxbxshkp6h-xycpor1hw_yawrkng5eumx0g"/> </relativelayout>
when try run this.,i got run time error....in ddms..i got..
02-09 12:25:55.735: warn/dalvikvm(360): threadid=3: thread exiting uncaught exception (group=0x4001aa28) 02-09 12:25:55.744: error/androidruntime(360): uncaught handler: thread main exiting due uncaught exception 02-09 12:25:55.774: error/androidruntime(360): java.lang.runtimeexception: unable instantiate activity componentinfo{com.make/com.make.simplegooglemaps}: java.lang.classnotfoundexception: com.make.simplegooglemaps in loader dalvik.system.pathclassloader@4376a9f8 02-09 12:25:55.774: error/androidruntime(360): @ android.app.activitythread.performlaunchactivity(activitythread.java:2324) 02-09 12:25:55.774: error/androidruntime(360): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2417) 02-09 12:25:55.774: error/androidruntime(360): @ android.app.activitythread.access$2100(activitythread.java:116) 02-09 12:25:55.774: error/androidruntime(360): @ android.app.activitythread$h.handlemessage(activitythread.java:1794) 02-09 12:25:55.774: error/androidruntime(360): @ android.os.handler.dispatchmessage(handler.java:99) 02-09 12:25:55.774: error/androidruntime(360): @ android.os.looper.loop(looper.java:123) 02-09 12:25:55.774: error/androidruntime(360): @ android.app.activitythread.main(activitythread.java:4203) 02-09 12:25:55.774: error/androidruntime(360): @ java.lang.reflect.method.invokenative(native method) 02-09 12:25:55.774: error/androidruntime(360): @ java.lang.reflect.method.invoke(method.java:521) 02-09 12:25:55.774: error/androidruntime(360): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:791) 02-09 12:25:55.774: error/androidruntime(360): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:549) 02-09 12:25:55.774: error/androidruntime(360): @ dalvik.system.nativestart.main(native method) 02-09 12:25:55.774: error/androidruntime(360): caused by: java.lang.classnotfoundexception: com.make.simplegooglemaps in loader dalvik.system.pathclassloader@4376a9f8 02-09 12:25:55.774: error/androidruntime(360): @ dalvik.system.pathclassloader.findclass(pathclassloader.java:243) 02-09 12:25:55.774: error/androidruntime(360): @ java.lang.classloader.loadclass(classloader.java:573) 02-09 12:25:55.774: error/androidruntime(360): @ java.lang.classloader.loadclass(classloader.java:532) 02-09 12:25:55.774: error/androidruntime(360): @ android.app.instrumentation.newactivity(instrumentation.java:1097) 02-09 12:25:55.774: error/androidruntime(360): @ android.app.activitythread.performlaunchactivity(activitythread.java:2316)
the errors classnotfoundexception
sure you're using correct class name , have declared class in manifest
??
Comments
Post a Comment