这是代码:
@Override
protected DVLAInformation doInBackground(String... params) {
try {
Intent intent = getIntent();
String dvlaNumFin = intent.getStringExtra("dvlaNumber");
final URL url = new URL("https://dvlasearch.appspot.com/DvlaSearch?licencePlate=" + dvlaNumFin + "&apikey=");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("USER-AGENT", "Mozilla/5.0");
connection.setRequestProperty("ACCEPT-LANGUAGE", "en-US,en;0.5");
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder responseOutput = new StringBuilder();
while ((line = br.readLine()) != null) {
responseOutput.append(line);
}
br.close();
DVLAInformation obj = new DVLAInformation(url.toString());
obj.readAndParseJSON(responseOutput.toString());
return obj;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
我的问题是如何从同一活动中的两个JSON URL返回对象
例如,我将有两个网址
final URL url = new URL("https://dvlasearch.appspot.com/DvlaSearch?licencePlate=" + dvlaNumFin + "&apikey=DvlaSearchDemoAccount");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
final URL url2 = new URL("https://dvlasearch.appspot.com/MotHistory?licencePlate=mt09nks&apikey=DvlaSearchDemoAccount");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
我不知道怎么回事:
DVLAInformation obj = new DVLAInformation(url.toString());
obj.readAndParseJSON(responseOutput.toString());
DVLAInformation obj2 = new DVLAInformation(url2.toString());
obj2.readAndParseJSON(responseOutput.toString());
return obj, obj2
对不起我的解释,我知道道路不正确,我只想解释一下我想做什么。
发现此CLICK但不明白如何应用