番号:
private class MyAsyncTask extends AsyncTask<Context, Integer, Long> {
private Context _context = null;
MyAsyncTask(Context context) {
_context = context;
}
protected Long doInBackground(Context... context) {
// if _context and context are the same, it doesn't matter
// which you use.
return 0;
}
protected void onProgressUpdate(Integer... progress) {
// update progress
}
protected void onPostExecute(Long result) {
// publish result
}
}
はその後マルチスレッドWRTにコンテキスト自体に関しては固有の問題がありません。
Context useMe = getApplicationContext();
MyAsyncTask task = new MyAsyncTask(useMe);
task.execute(useMe); // should use this if provided, otherwise, what was in constructor
http://developer.android.com/reference/android/os/AsyncTask.html –
@ Rahulを参照してください – midnight