android - Caused by: java.lang.NumberFormatException -
in application trying display latitude , longitude of multiple points on google map coordinates stored in sqllite database. here map.class display point.
public class map extends mapactivity { private mapview map = null; private mylocationoverlay me = null; list<overlay> mapoverlays; boolean flag; public static context context; arraylist<article> marticles; edittext search; dbhelper helper; geopoint point; mapview mapview; drawable marker; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.aproximite); helper = dbhelper.getinstance(this);// <= data mysqllitedatabase map = (mapview) findviewbyid(r.id.mapview); map.getcontroller().setcenter(getpoint(40.76793169992044, -73.98180484771729)); map.getcontroller().setzoom(17); map.setbuiltinzoomcontrols(true); mapoverlays = map.getoverlays(); marker = getresources().getdrawable(r.drawable.icone_sur_carte); marker.setbounds(0, 0, marker.getintrinsicwidth(), marker.getintrinsicheight()); map.getoverlays().add(new sitesoverlay(marker, map));//<===error occurance me = new mylocationoverlay(this, map); map.getoverlays().add(me); } @override public void onresume() { super.onresume(); me.enablecompass(); } public mapview getmapview() { return this.map; } @override public void onpause() { super.onpause(); me.disablecompass(); } @override protected boolean isroutedisplayed() { return (false); } @override public boolean onkeydown(int keycode, keyevent event) { if (keycode == keyevent.keycode_s) { map.setsatellite(!map.issatellite()); return (true); } else if (keycode == keyevent.keycode_z) { map.displayzoomcontrols(true); return (true); } return (super.onkeydown(keycode, event)); } private geopoint getpoint(double lat, double lon) { return (new geopoint((int) (lat * 1000000.0), (int) (lon * 1000000.0))); } private class sitesoverlay extends itemizedoverlay<overlayitem> { private list<overlayitem> items = new arraylist<overlayitem>(); private drawable marker = null; private overlayitem indrag = null; private imageview dragimage = null; private int xdragimageoffset = 0; private int ydragimageoffset = 0; private int xdragtouchoffset = 0; private int ydragtouchoffset = 0; private context c; public int selectedindex = -1; private final bitmap bitmap; private view view = null; private boolean ispinch = false; public sitesoverlay(drawable marker, mapview mapview) { super(boundcenter(marker)); this.marker = marker; c = mapview.getcontext(); dragimage = (imageview) findviewbyid(r.id.drag); xdragimageoffset = dragimage.getdrawable().getintrinsicwidth() / 2; ydragimageoffset = dragimage.getdrawable().getintrinsicheight(); marticles = helper.getarticleslist(); (int i=0;i<marticles.size();i++){ double slat =double.valueof(marticles.get(i).getlatitude().tostring()); double vlong = double.valueof(marticles.get(i).getlongitude().tostring()); geopoint pt = new geopoint((int) (slat * 1e6), (int) (vlong * 1e6)); log.e("lat long", "--- "+slat); // map.mc.animateto(pt); items.add(new overlayitem(pt, marticles.get(i).getnom().tostring(), "bendigo")); boundcenter(marker); } bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.icone_sur_carte); populate(); } @override protected overlayitem createitem(int i) { return (items.get(i)); } @override public void draw(canvas canvas, mapview mapview, boolean shadow) { super.draw(canvas, mapview, shadow); boundcenterbottom(marker); } @override public int size() { return (items.size()); } public void refresh() { populate(); } public void clear() { items.clear(); resetlastfocuesindex(); } public void resetlastfocuesindex() { setlastfocusedindex(-1); selectedindex = -1; } @override protected boolean ontap(final int index) { if ( ispinch ){ return false; }else{ /* getmapview().setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { if (!items.isempty()) { if (view != null) { view.setvisibility(view.gone); getmapview().invalidate(); } } getmapview().invalidate(); return true; } });*/ if (view != null) { view.setvisibility(view.gone); getmapview().removeview(view); getmapview().invalidate(); flag = false; view = null; } view = getlayoutinflater().inflate(r.layout.balloon_overlay, null); linearlayout layout = (linearlayout) view .findviewbyid(r.id.balloon_main_layout); layout.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); view.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); view.setbackgroundresource(r.drawable.balloon_overlay_bg_selector); imageview image = (imageview) view .findviewbyid(r.id.balloon_disclosure); textview text = (textview) view .findviewbyid(r.id.balloon_item_title); text.settext(items.get(index).gettitle()); if (items.get(index).gettitle() != null && items.get(index).gettitle().equals("me") == false) { image.setimageresource(r.drawable.icone_sur_carte); } projection projection = getmapview().getprojection(); point point = new point(); projection.topixels(items.get(index).getpoint(), point); int x = (int) (view.getwidth() / 2f); int y = -bitmap.getheight() - 3; mapview.layoutparams lp = new mapview.layoutparams( viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content, items.get(index) .getpoint(), x, y, mapview.layoutparams.bottom_center); getmapview().removeview(view); getmapview().invalidate(); getmapview().addview(view, lp); getmapview().invalidate(); view.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { if (!items.isempty()) { if (view != null) { view.setvisibility(view.gone); getmapview().invalidate(); system.out.println("selectedindex: "+selectedindex); } } getmapview().invalidate(); } }); selectedindex = index; return true; } } @override public boolean ontouchevent(motionevent event, mapview mapview) { final int action = event.getaction(); final int x = (int) event.getx(); final int y = (int) event.gety(); boolean result = false; if (action == motionevent.action_down) { (overlayitem item : items) { point p = new point(0, 0); map.getprojection().topixels(item.getpoint(), p); if (hittest(item, marker, x - p.x, y - p.y)) { result = true; indrag = item; items.remove(indrag); populate(); xdragtouchoffset = 0; ydragtouchoffset = 0; setdragimageposition(p.x, p.y); dragimage.setvisibility(view.visible); xdragtouchoffset = x - p.x; ydragtouchoffset = y - p.y; ispinch=false; break; } } } else if (action == motionevent.action_move && indrag != null) { if (view != null) { if (view.getvisibility() != 0) { log.e("touch", " out move"); setdragimageposition(x, y); result = true; ispinch=true; }else{ setdragimageposition(x, y); ispinch=false; } }else{ setdragimageposition(x, y); result = true; ispinch=true; } } else if (action == motionevent.action_up && indrag != null) { dragimage.setvisibility(view.gone); geopoint pt = map.getprojection().frompixels( x - xdragtouchoffset, y - ydragtouchoffset); overlayitem todrop = new overlayitem(pt, indrag.gettitle(), indrag.getsnippet()); log.e("touch", " out last" + pt.getlatitudee6()); items.add(todrop); populate(); indrag = null; result = true; ispinch = false; } return (ispinch || super.ontouchevent(event,mapview)); } private void setdragimageposition(int x, int y) { relativelayout.layoutparams lp = (relativelayout.layoutparams) dragimage.getlayoutparams(); lp.setmargins(x - xdragimageoffset - xdragtouchoffset, y - ydragimageoffset - ydragtouchoffset, 0, 0); dragimage.setlayoutparams(lp); } } }
when run code application force code , log displays following error.
05-25 14:18:38.125: e/androidruntime(11240): fatal exception: main 05-25 14:18:38.125: e/androidruntime(11240): java.lang.runtimeexception: unable start activity componentinfo{.tabsample}: java.lang.runtimeexception: unable start activity componentinfo{.map.map}: java.lang.numberformatexception 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.access$1500(activitythread.java:117) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread$h.handlemessage(activitythread.java:935) 05-25 14:18:38.125: e/androidruntime(11240): @ android.os.handler.dispatchmessage(handler.java:99) 05-25 14:18:38.125: e/androidruntime(11240): @ android.os.looper.loop(looper.java:130) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.main(activitythread.java:3687) 05-25 14:18:38.125: e/androidruntime(11240): @ java.lang.reflect.method.invokenative(native method) 05-25 14:18:38.125: e/androidruntime(11240): @ java.lang.reflect.method.invoke(method.java:507) 05-25 14:18:38.125: e/androidruntime(11240): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:842) 05-25 14:18:38.125: e/androidruntime(11240): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 05-25 14:18:38.125: e/androidruntime(11240): @ dalvik.system.nativestart.main(native method) 05-25 14:18:38.125: e/androidruntime(11240): caused by: java.lang.runtimeexception: unable start activity componentinfo{.map.map}: java.lang.numberformatexception 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.startactivitynow(activitythread.java:1491) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.localactivitymanager.movetostate(localactivitymanager.java:127) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.localactivitymanager.startactivity(localactivitymanager.java:339) 05-25 14:18:38.125: e/androidruntime(11240): @ android.widget.tabhost$intentcontentstrategy.getcontentview(tabhost.java:657) 05-25 14:18:38.125: e/androidruntime(11240): @ android.widget.tabhost.setcurrenttab(tabhost.java:329) 05-25 14:18:38.125: e/androidruntime(11240): @ .tabsample.setproximite(tabsample.java:659) 05-25 14:18:38.125: e/androidruntime(11240): @ .tabsample.oncreate(tabsample.java:98) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.performlaunchactivity(activitythread.java:1615) 05-25 14:18:38.125: e/androidruntime(11240): ... 11 more 05-25 14:18:38.125: e/androidruntime(11240): caused by: java.lang.numberformatexception 05-25 14:18:38.125: e/androidruntime(11240): @ org.apache.harmony.luni.util.floatingpointparser.parsedblimpl(native method) 05-25 14:18:38.125: e/androidruntime(11240): @ org.apache.harmony.luni.util.floatingpointparser.parsedouble(floatingpointparser.java:283) 05-25 14:18:38.125: e/androidruntime(11240): @ java.lang.double.parsedouble(double.java:318) 05-25 14:18:38.125: e/androidruntime(11240): @ java.lang.double.valueof(double.java:356) 05-25 14:18:38.125: e/androidruntime(11240): @ .map.map$sitesoverlay.<init>(map.java:156) 05-25 14:18:38.125: e/androidruntime(11240): @ .map.map.oncreate(map.java:78) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 05-25 14:18:38.125: e/androidruntime(11240): @ android.app.activitythread.performlaunchactivity(activitythread.java:1615) 05-25 14:18:38.125: e/androidruntime(11240): ... 20 more 05-25 14:23:44.253: i/process(11240): sending signal. pid: 11240 sig: 9
also want know how integrade background service in map.class
as in logcat:
at .tabsample.setproximite(tabsample.java:659)
here have numberformatexception - conversion string -> integer / float wrong. best way use debugger in eclipse shuld allow step through problem.