我正在尝试使用 asynctask 从谷歌获取 JSON 数据。但是我收到很多错误,我不知道为什么。我是android开发的新手,我对它很感兴趣,然后现在又退出了:P。
并单击执行异步任务的按钮
new usdjson().execute();
这是我的异步任务
private class usdjson extends AsyncTask<URL, Void, JSONObject> {
@Override
protected Boolean doInBackground(URL... urls) {
// I get this from Boolean : The return type is incompatible with AsyncTask<URL,Void,JSONObject>.doInBackground(URL[])
URL url = new URL(requestUrl);
loadJSON(url);
}
@Override
protected void onPostExecute(JSONObject jsonData) {
try {
String USD = json.getJSONArray("rhs");
//I get this from json. :json cannot be resolved
}
}
public void loadJSON(URL url) {
JSONParser jParser = new JSONParser();
//I get this from JSONPareser JSONParser cannot be resolved to a type
JSONObject json = jParser.getJSONFromUrl(url);
return json;
//Void methods cannot return a value
}
抱歉太长了