添加第三个cursor.getString()时我的应用程序崩溃了

时间:2017-02-14 12:41:36

标签: android google-maps

我有这段代码,当我使用两者中的任何一个(getString(1),getString(3),getString(4))时似乎都很好但是当我使用它们中的三个并将它们分配到一个变量,我的应用程序似乎崩溃。

     String replaceNodeFormat = joinNodes_all.replace(",,", ","); //  ,1-5,,5-6,,6-7, => ,1-5,5-6,6-7,
    cursor = db.rawQuery("SELECT * FROM angkutan_umum where simpul like '%" + replaceNodeFormat + "%'", null);
    cursor.moveToFirst();
    cursor.moveToPosition(0);
    // ada 1 angkot yg melewati jalur dari awal sampek akhir
    if(cursor.getCount() > 0){

        String transpoName = cursor.getString(1).toString();
        String type = cursor.getString(3).toString();
        // get coordinate
        cursor = db.rawQuery("SELECT jalur FROM graph where simpul_awal = '" + initialNodeDijkstra + "'", null);
        cursor.moveToFirst();
        String json_coordinate = cursor.getString(0).toString();

        // manipulating JSON
        JSONObject jObject = new JSONObject(json_coordinate);
        JSONArray jArrCoordinates = jObject.getJSONArray("coordinates");
        JSONArray latlngs = jArrCoordinates.getJSONArray(0);

        // first latlng
        Double lats = latlngs.getDouble(0);
        Double lngs = latlngs.getDouble(1);
        googleMap.addMarker(new MarkerOptions()
        .position(new LatLng(lats, lngs))
        .title(type)
        .snippet(transpoName)
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.car))).showInfoWindow();
        transpoType = type;
        // die()\
        return;
    }

任何帮助将不胜感激,提前谢谢!

编辑:logcat:

02-14 20:50:49.091 1280-1280/com.app.dijkstra I/Radius Value: 1.7218877092846008   KM  2 Meter   2
02-14 20:50:49.441 1280-1280/com.app.dijkstra I/System.out: {"nodes":["91-133"],"coordinates":[[14.67332761020003,121.04918718338013],[14.673304257621103,121.04900479316711],[14.673216036744883,121.0487312078476],[14.673133005299466,121.048444211483],[14.673078515896298,121.04820817708969],[14.672964347578985,121.04778975248337],[14.672865747620646,121.04736059904099],[14.672772337092828,121.0469314455986],[14.672689305479047,121.04650497436523],[14.67257773169844,121.04606509208679],[14.672486915788495,121.04564666748047],[14.672396099840867,121.04522287845612]],"distance_metres":[439.6285858154297]}
02-14 20:50:49.451 1280-1280/com.app.dijkstra I/System.out: {"nodes":["133-102"],"coordinates":[[14.672396099840867,121.04522287845612],[14.67228712065396,121.04479104280472],[14.672175546668285,121.0443189740181],[14.672079541100178,121.04393810033798],[14.672019861942033,121.04366719722748],[14.671984832863355,121.04343116283417]],"distance_metres":[198.3895092010498]}
02-14 20:50:49.461 1280-1280/com.app.dijkstra I/System.out: {"nodes":["102-133"],"coordinates":[[14.671984832863355,121.04343116283417],[14.672019861942033,121.04366719722748],[14.672079541100178,121.04393810033798],[14.672175546668285,121.0443189740181],[14.67228712065396,121.04479104280472],[14.672396099840867,121.04522287845612]],"distance_metres":[198.3895092010498]}
02-14 20:50:49.461 1280-1280/com.app.dijkstra I/System.out: {"nodes":["133-91"],"coordinates":[[14.672396099840867,121.04522287845612],[14.672486915788495,121.04564666748047],[14.67257773169844,121.04606509208679],[14.672689305479047,121.04650497436523],[14.672772337092828,121.0469314455986],[14.672865747620646,121.04736059904099],[14.672964347578985,121.04778975248337],[14.673078515896298,121.04820817708969],[14.673133005299466,121.048444211483],[14.673216036744883,121.0487312078476],[14.673304257621103,121.04900479316711],[14.67332761020003,121.04918718338013]],"distance_metres":[439.6285858154297]}
02-14 20:50:49.731 1280-1280/com.app.dijkstra I/System.out: {"nodes":["94-134"],"coordinates":[[14.67188493508969,121.06860637664795],[14.671903098324657,121.0684186220169],[14.671913477315394,121.06807261705399],[14.671910882567754,121.06783658266068],[14.67190828782009,121.06739938259125],[14.671934235295378,121.06714189052582],[14.671988724983485,121.06667786836624],[14.672082135845821,121.0661119222641],[14.672165167689977,121.06554597616196],[14.672268957450862,121.06489956378937],[14.672333826026415,121.06443285942078],[14.672419452516714,121.0638776421547],[14.672489510529303,121.0633036494255],[14.672621842269654,121.06243193149567],[14.672702279170784,121.06192231178284]],"distance_metres":[726.678388595581]}
02-14 20:50:49.741 1280-1280/com.app.dijkstra I/System.out: {"nodes":["134-91"],"coordinates":[[14.672702279170784,121.06192231178284],[14.672748984454628,121.06162458658218],[14.672839800255808,121.06107205152512],[14.672933210754836,121.06052219867706],[14.673016242276063,121.05993747711182],[14.673088894831286,121.05938225984573],[14.673177115758765,121.0588189959526],[14.673265336650669,121.05827182531357],[14.673335394392442,121.05768710374832],[14.673421020490832,121.05713188648224],[14.673517025470357,121.05656325817108],[14.673602651497655,121.05602145195007],[14.673685682764846,121.05544745922089],[14.673758335097787,121.05488419532776],[14.673820608506832,121.05433166027069],[14.673877692449555,121.05373620986938],[14.673872503000824,121.0531997680664],[14.673869908276417,121.05266869068146],[14.673812824331671,121.05204910039902],[14.673737577290835,121.05152070522308],[14.673659735497232,121.05108350515366],[14.673517025470357,121.05043172836304],[14.673405452111783,121.04991406202316],[14.673382099541163,121.04950904846191],[14.67332761020003,121.04918718338013]],"distance_metres":[1386.8701438903809]}
02-14 20:50:49.751 1280-1280/com.app.dijkstra I/System.out: {"nodes":["91-134"],"coordinates":[[14.67332761020003,121.04918718338013],[14.673382099541163,121.04950904846191],[14.673405452111783,121.04991406202316],[14.673517025470357,121.05043172836304],[14.673659735497232,121.05108350515366],[14.673737577290835,121.05152070522308],[14.673812824331671,121.05204910039902],[14.673869908276417,121.05266869068146],[14.673872503000824,121.0531997680664],[14.673877692449555,121.05373620986938],[14.673820608506832,121.05433166027069],[14.673758335097787,121.05488419532776],[14.673685682764846,121.05544745922089],[14.673602651497655,121.05602145195007],[14.673517025470357,121.05656325817108],[14.673421020490832,121.05713188648224],[14.673335394392442,121.05768710374832],[14.673265336650669,121.05827182531357],[14.673177115758765,121.0588189959526],[14.673088894831286,121.05938225984573],[14.673016242276063,121.05993747711182],[14.672933210754836,121.06052219867706],[14.672839800255808,121.06107205152512],[14.672748984454628,121.06162458658218],[14.672702279170784,121.06192231178284]],"distance_metres":[1386.8701438903809]}
02-14 20:50:49.761 1280-1280/com.app.dijkstra I/System.out: {"nodes":["134-94"],"coordinates":[[14.672702279170784,121.06192231178284],[14.672621842269654,121.06243193149567],[14.672489510529303,121.0633036494255],[14.672419452516714,121.0638776421547],[14.672333826026415,121.06443285942078],[14.672268957450862,121.06489956378937],[14.672165167689977,121.06554597616196],[14.672082135845821,121.0661119222641],[14.671988724983485,121.06667786836624],[14.671934235295378,121.06714189052582],[14.67190828782009,121.06739938259125],[14.671910882567754,121.06783658266068],[14.671913477315394,121.06807261705399],[14.671903098324657,121.0684186220169],[14.67188493508969,121.06860637664795]],"distance_metres":[726.678388595581]}
02-14 20:50:49.771 1280-1280/com.app.dijkstra I/System.out: in : 133 & dn : 134
02-14 20:50:49.991 1280-1280/com.app.dijkstra I/System.out: null
02-14 20:50:50.031 1280-1710/com.app.dijkstra I/Process: Sending signal. PID: 1280 SIG: 9

0 个答案:

没有答案