クラスに到達していませんonPostExecute
。AsyncTask
onClick
ダイアログボックス内で、このようにタスクを呼び出します。
new HelpfulTask().execute(passing);
注: 上記のコードにカーソルを合わせると、次の警告が表示されます。
varargs パラメータに対して、ArrayList の汎用配列が作成されます。
それが何を意味するのかわかりませんが、それが私のタスクの実行さえ妨げているのですか?
タスクコードは次のとおりです。
protected class UnHelpfulTask extends
AsyncTask<ArrayList<String>, Void, ArrayList<String>> {
ArrayList<String> passed;
protected ArrayList<String> doInBackground(ArrayList<String>... passing) {
passed = passing[0];
String url_select = "http://www.---.com/---/bad.php";
ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("item", passed.get(0)));
param.add(new BasicNameValuePair("text", passed.get(1)));
param.add(new BasicNameValuePair("category", passed.get(2)));
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_select);
try {
httpPost.setEntity(new UrlEncodedFormEntity(param));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
// read content
is = httpEntity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
return null;
}
InputStream is = null;
String result = "";
protected void onPostExecute(Void v) {
Toast.makeText(getContext(), "You have voted this down!",
Toast.LENGTH_SHORT).show();
}
}
実行時にエラーが発生せずonPostExecute
、Toast が表示されません。 (注: これは 内の内部クラスですArrayAdapter.
) また、トーストを追加して、ArrayList
ラップが適切に展開されているかどうかを確認し、それを に入れましたonPostExecute
が、どちらも表示されませんでした。
このタスクが実行されているかどうかをテストするにはどうすればよいですか?