意外的JDWP错误:14无法评估java.net.URL.toString()

时间:2016-05-25 15:37:41

标签: php android mysql google-maps

我试图在我的mySQL数据库中创建Google地图上的标记,但它无法正常工作。地图确实出现但没有标记。任何人都可以告诉我什么是错的以及我需要改变什么,因为我收到了这个错误: 意外的JDWP错误:14无法评估java.net.URL.toString()。 另外,我的数据库在MySql中

下面是我的MarkerTask类,它扩展了AsyncTask

class MarkerTask extends AsyncTask<Void, Void, String> {

        public static final String LOG_TAG = "ExampleApp";

        public static final String SERVICE_URL = "http://192.168.48.14/stations.php";

        // Invoked by execute() method of this object
        @Override
        protected String doInBackground(Void... args) {

            HttpURLConnection conn = null;
            InputStream in = null;
            String result = "";

            try {
                URL url = new URL(SERVICE_URL);
                conn = (HttpURLConnection) url.openConnection();// here is where i got the error
                conn.connect();
                in = conn.getInputStream();


            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8"));
                String line = null;
                while ((line = reader.readLine()) != null) {
                    result += line;
                }
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return result;

        }


            // Executed after the complete execution of doInBackground() method
            @Override
            protected void onPostExecute (String result){

                try {
                    // De-serialize the JSON string into an array
                    JSONArray jsonArray = new JSONArray(result);
                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject jsonObj = jsonArray.getJSONObject(i);

                        LatLng latLng = new LatLng(jsonObj.getJSONArray("latlng").getDouble(0),
                        jsonObj.getJSONArray("latlng").getDouble(1));


                        // Create a marker for each station in the JSON data.
                        map.addMarker(new MarkerOptions()
                                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))
                                .title(jsonObj.getString("nume"))
                                .position(latLng));
                    }
                } catch (JSONException e) {
                    Log.e(LOG_TAG, "Error processing JSON", e);
                }

            }
        }
    }

这是我的php

  $username = "root";
$password = "";
$hostname = "localhost"; 

//connection to the database
@$dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");

$selected = mysql_select_db("incercare",$dbhandle)or die("Could not select licenta");


    $sql="SELECT id_st, nume, CONCAT_WS(\",\",lat, lng) AS latlng FROM statii";
    $result = mysql_query($sql);
    $response= array();
    while($row= mysql_fetch_assoc($result)){

        $response[]=array(
                            'nume'          => $row['nume'],
                            'latlng'        => explode(',', $row['latlng']),
                            'id_st'         => $row['id_st']
                            );
    }

$bd_json = json_encode($response);
echo json_encode($response);
?>

这是我的json输出

[{"nume":"Merge in sfarsit","latlng":["45.659721","25.606859"],"id_st":"5"},{"nume":"Memo Cantina","latlng":["45.655075","25.581560"],"id_st":"6"}]

0 个答案:

没有答案