我想连接我的android设备到我的sql数据库使用我的本地ip地址我的电脑,但没有任何反应。我有错误。httpurlconnection本地ip地址
超时而检索用于BufferedReader中[在BufferedReader.class所附的javadoc [java.io中的[在E:\安装\应用\ Eclipse的\ SDK \ Android的SDK-WINDOWS \平台\ Android的23 \一个droid.jar]]]
从我的logcat
了java.lang.RuntimeException:发生错误而执行doInBackground()
引起:java.lang.ClassCastException:libcore.net。 http.HttpURLConnectionImpl不能转换为javax.net.ssl.HttpsURLConnection
class BackgroundTask extends AsyncTask< Void, Void, String>{
String json_url = "http://192.168.1.106/sample/sample.php";
HttpURLConnection httpsURLConnection = null;
@Override
protected String doInBackground(Void... params) {
try {
URL url = new URL(json_url);
httpsURLConnection = (HttpsURLConnection) url.openConnection();
InputStream inputStream = httpsURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
while((JSON_STRING = bufferedReader.readLine()) != null){
stringBuilder.append(JSON_STRING+"\n");
}
bufferedReader.close();
inputStream.close();
httpsURLConnection.disconnect();
return stringBuilder.toString().trim();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
@Override
protected void onPostExecute(String result) {
TextView textView = (TextView) findViewById(R.id.tvDisplay);
textView.setText(result);
}
}
任何建议,将不胜感激。
将错误添加到您的帖子。在这篇文章中,你错过了一个'}'。我希望它存在于你的代码中。 –
超时检索BufferedReader [在BufferedReader.class [在E:\ Installer \ Application \ Eclipse \ sdk \ android-sdk-windows \ platforms \ android-23 \ android.jar]中的java.io中附加的javadoc] ] – ariel
java.lang.RuntimeException:执行doInBackground()时发生错误 - 来自我的日志cat – ariel