Android基础:在UI线程中运行代码
从在UI线程中运行代码的角度来看,在以下方面有什么区别:MainActivity.this.runOnUiThread(new Runnable() {
public void run() {
Log.d("UI thread", "I am the UI thread");
}});
或MainActivity.this.myView.post(new Runnable() {
public void run() {
Log.d("UI thread", "I am the UI thread");
}});
和private class BackgroundTask extends AsyncTask {
protected void onPostExecute(Bitmap result) {
Log.d("UI thread", "I am the UI thread");
}}