• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Navigation voice changer app for Android


Commit MetaInfo

Revisiond57a0ccc582de1119e1663bc9b0f3628fc9a1970 (tree)
Time2013-07-30 21:53:45
AuthorHMML <hmml3939@gmai...>
CommiterHMML

Log Message

Tune http client closing.

Change Summary

Incremental Difference

--- a/src/jp/nekoteki/android/navivoicechanger/DownloadActivity.java
+++ b/src/jp/nekoteki/android/navivoicechanger/DownloadActivity.java
@@ -87,11 +87,11 @@ public class DownloadActivity extends Activity {
8787
8888 @Override
8989 protected RemoteVoiceData[] doInBackground(Object... params) {
90+ AndroidHttpClient client = AndroidHttpClient.newInstance("NaviVoiceChanger");
9091 try {
9192 String url = (String) params[0];
9293 this.view = (ListView) params[1];
9394 this.adapter = (RemoteVoiceDataAdapter) params[2];
94- AndroidHttpClient client = AndroidHttpClient.newInstance("NaviVoiceChanger");
9595 Log.i(this.getClass().toString(), "Loading URL: "+url);
9696 HttpResponse res;
9797 res = client.execute(new HttpGet(url));
@@ -99,7 +99,6 @@ public class DownloadActivity extends Activity {
9999 InputStream json_stream = res.getEntity().getContent();
100100 RemoteVoiceData[] vdlist = JSON.decode(json_stream, RemoteVoiceData[].class);
101101 json_stream.close();
102- client.close();
103102 return vdlist;
104103 } catch (IOException e) {
105104 Log.d(this.getClass().toString(), "Failed to load from server.");
@@ -109,6 +108,12 @@ public class DownloadActivity extends Activity {
109108 Log.e(this.getClass().toString(), "Unknwon Exception in AsyncTask!!");
110109 e.printStackTrace();
111110 return null;
111+ } finally {
112+ try {
113+ client.close();
114+ } catch (Exception e) {
115+ // ignore
116+ }
112117 }
113118 }
114119