0
public class ODKortrijkWebservice extends AsyncTask<ODKortrijkInterface, Void, Void>{
Context context;
String myurl = "http://data.kortrijk.be/middenstand/winkels_markten";
URL url;
public ODKortrijkWebservice(Context context){
this.context = context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
@Override
protected Void doInBackground(ODKortrijkInterface... params) {
processXML(getData());
return null;
}
private void processXML(Document data) {
if(data!=null){
Log.d("Root",data.getDocumentElement().getNodeName());
}
}
public Document getData(){
try {
url = new URL(myurl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
InputStream inputStream = connection.getInputStream();
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document xmlDoc = builder.parse(inputStream);
return xmlDoc;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}}
07-27 17:11:56.867 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: java.io.FileNotFoundException: http://data.kortrijk.be/middenstand/winkels_markten
07-27 17:11:56.867 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:206)
07-27 17:11:56.867 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at com.example.hoofdgebruiker.winkelskortrijk.Utill.ODKortrijkWebservice.getData(ODKortrijkWebservice.java:70)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at com.example.hoofdgebruiker.winkelskortrijk.Utill.ODKortrijkWebservice.doInBackground(ODKortrijkWebservice.java:55)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at com.example.hoofdgebruiker.winkelskortrijk.Utill.ODKortrijkWebservice.doInBackground(ODKortrijkWebservice.java:32)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:292)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
07-27 17:11:56.868 17601-17726/com.example.hoofdgebruiker.winkelskortrijk W/System.err: at java.lang.Thread.run(Thread.java:818)
該網站存在並正在運行。我從我的第二個活動中調用這個,將上下文作爲(this)傳遞。我在做什麼錯誤,這是行不通的?我一直在努力獲得任何工作,所以我真的可以使用一些幫助從webservice文件中找不到數據
編輯:我已經允許我的Android清單中的互聯網連接,所以這也不是問題。我的代碼出了問題,我不知道什麼是