AsyncTask を使用します....次のスニペットは、参考のために AsyncTask を実行します。
プライベート クラス doSomethingDelayed extends AsyncTask {
private int num_runs = 0;
@Override
protected Void doInBackground(Void... gurk) {
Log.v(TAG, "going into postData");
long ms_before = SystemClock.uptimeMillis();
try {
Log.v(TAG, "Time Now is " + ms_before);
postData();
Log.v(TAG, "coming out of postData");
publishProgress(num_runs);
} catch (Exception e) {
System.out.println("--DoSomeThing--" + e.getMessage());
}
return null;
}
@Override
protected void onCancelled() {
Context context = getApplicationContext();
int duration = Toast.LENGTH_LONG;
}
@Override
protected void onProgressUpdate(Integer... num_runs) {
Context context = getApplicationContext();
}
}
}
}