Skip to content

Instantly share code, notes, and snippets.

@mryp
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mryp/ec7ffd15a2a3b41afe97 to your computer and use it in GitHub Desktop.
Save mryp/ec7ffd15a2a3b41afe97 to your computer and use it in GitHub Desktop.
非同期処理(AsyncTask)
import android.os.AsyncTask;
public class SampleAsyncTask extends AsyncTask<String, Integer, Integer> {
/**
* 前処理
*/
@Override
protected void onPreExecute() {
//開始前の初期化処理等を行う
}
/**
* 処理開始(非同期)
*/
@Override
protected Integer doInBackground(String... text) {
//非同期の実処理を行う
return 0;
}
/**
* 更新処理
*/
@Override
protected void onProgressUpdate(Integer... progress) {
//現在の処理状況を反映する(プログレスダイアログなど)
}
/**
* 完了処理
*/
@Override
protected void onPostExecute(Integer result) {
//後処理を行う
}
}
//処理開始
SampleAsyncTask task = new SntpTimeUpdateAsyncTask();
task.execute("text[0]の文字列");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment