呼び出したアプリケーションが終了した場合、戻り値または Aysnc タスクへの呼び出しはどうなりますか。
Aysnc タスクでネットワーク操作を呼び出し、それを呼び出した UI スレッドが操作を終了したとします。
私の目的は、N/W コールで受信したデータを保存することです。そのため、次回コールをやり直す必要がありますか?
以下は、doInBackground() で SOAP リクエストを作成し、リクエストがオンになっている間に、Aync タスクを呼び出したメイン UI が何らかの理由で停止/終了するコード スニペットです。私の対応はどうなりますか?将来の使用のために応答を保存するにはどうすればよいですか。
Code:
class SOAPCallAyncTask1 extends AsyncTask<String, String, String> {
ProgressDialog pd = null;
@Override
protected void onPreExecute() {
super.onPreExecute();
pd = new ProgressDialog(SoapMainActivity.this);
pd.setMessage("Please wait...");
pd.setCancelable(false);
pd.show();
}
@Override
protected String doInBackground(String... params) {
String theResult = "";
byte[] result = null;
try {
result = callSOAPServer();
theResult = new String(result);
Log.d("R-Doit in backgound", theResult);
}
catch (Exception e) {
e.printStackTrace();
}
return theResult;
}
@Override
protected void onPostExecute(String theResult) {
super.onPostExecute(theResult);
pd.dismiss();
Log.d("R-Result", theResult);
}
}