android - Problems while trying to see the route between two locations using Google Maps -
i'm using background thread read sqlite database gps data...and store in geopoints.....after finish reading data wanna use intent in order see route described data.
here code:
protected list<geopoint> doinbackground(dbadapter... db) { try { db[0].opendatabase(); cursor c = db[0].getalldata(); if (c.movetofirst()) { { longitude = integer.parseint(c.getstring(0)); latitude = integer.parseint(c.getstring(1)); p = new geopoint(latitude, longitude); geopointsarray.add(p); } while (c.movetonext()); } c.close(); db[0].close(); } catch (exception e) { log.d("eroare", "doinbackground", e); } return geopointsarray; } protected void onpostexecute(list<geopoint> geopointsarray) { int = geopointsarray.size(); srcplace = geopointsarray.get(1); destplace = geopointsarray.get(i); intent intent = new intent(android.content.intent.action_view, uri.parse(" http://maps.google.com?t=k&saddr=" + srcplace + "&daddr=" + destplace)); startactivity(intent); }
but something, somewhere goes terribly wrong , next output of logcat:
uncaught handler: thread main exiting due uncaught exception java.lang.indexoutofboundsexception: invalid location 4180, size 4180 @ java.util.arraylist.get(arraylist.java:341) @ test.android.screen_database$inittask.onpostexecute(screen_database.java:201) @ test.android.screen_database$inittask.onpostexecute(screen_database.java:1) @ android.os.asynctask.finish(asynctask.java:417) @ android.os.asynctask.access$300(asynctask.java:127) @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:429) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:123) @ android.app.activitythread.main(activitythread.java:4363) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:521) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) @ dalvik.system.nativestart.main(native method)
don't forget wanna see path on map between 2 points...so if u have suggestions url more welcomed!
update:this second fc
thread exiting uncaught exception (group=0x4001b188) uncaught handler: thread main exiting due uncaught exception android.content.activitynotfoundexception: no activity found handle intent { act=android.intent.action.view dat= http://maps.google.com?t=k&saddr=48856838,2351068&daddr=48927049,2357270 } @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1408) @ android.app.instrumentation.execstartactivity(instrumentation.java:1378) @ android.app.activity.startactivityforresult(activity.java:2749) @ android.app.activity.startactivity(activity.java:2855) @ test.android.screen_database$inittask.onpostexecute(screen_database.java:205) @ test.android.screen_database$inittask.onpostexecute(screen_database.java:1) @ android.os.asynctask.finish(asynctask.java:417) @ android.os.asynctask.access$300(asynctask.java:127) @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:429) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:123) @ android.app.activitythread.main(activitythread.java:4363) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:521) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) @ dalvik.system.nativestart.main(native method)
the array index based on zero. if i
size, need call destplace = geopointsarray.get(i - 1);
. , source should 0
, not 1
.
protected void onpostexecute(list<geopoint> geopointsarray) { int = geopointsarray.size(); srcplace = geopointsarray.get(0); destplace = geopointsarray.get(i - 1); intent intent = new intent(android.content.intent.action_view, uri.parse(" http://maps.google.com?t=k&saddr=" + srcplace + "&daddr=" + destplace)); startactivity(intent); }
Comments
Post a Comment