Android アプリケーションに次のコードがあります。
public static HttpResponse dbPost(String handlerUrl, List<NameValuePair> postData) {
HttpClient httpclient = new DefaultHttpClient();
String postUrl = constants.postUrl();
HttpPost httppost = new HttpPost(postUrl);
HttpResponse response = null;
System.out.print("Catch 0");
try {
httppost.setEntity(new UrlEncodedFormEntity(postData));
response = httpclient.execute(httppost);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.print("Catch 1");
return response;
}
このブロックを呼び出すボタンがあります。ボタンを押すと、コンソールに「Catch 0」が表示されます (「Catch 1」ではありません)。ボタンをもう一度押すと (同じインスタンス)、コンソールに「Catch1Catch0」と出力されます。どうしたの?
私はJavaに少し慣れていないので、我慢してください。