???????磬???AsyncTask??????????????

????[java] view plaincopyprint?

????public void onClick(View v) {

????new DownloadImageTask().execute("http://example.com/image.png");

????}

????private class DownloadImageTask extends AsyncTask {

????/** The system calls this to perform work in a worker thread and

????* delivers it the parameters given to AsyncTask.execute() */

????protected Bitmap doInBackground(String... urls) {

????return loadImageFromNetwork(urls[0]);

????}

????/** The system calls this to perform work in the UI thread and delivers

????* the result from doInBackground() */

????protected void onPostExecute(Bitmap result) {

????mImageView.setImageBitmap(result);

????}

????}

????public void onClick(View v) {

????new DownloadImageTask().execute("http://example.com/image.png");

????}

????private class DownloadImageTask extends AsyncTask {

????/** The system calls this to perform work in a worker thread and

????* delivers it the parameters given to AsyncTask.execute() */

????protected Bitmap doInBackground(String... urls) {

????return loadImageFromNetwork(urls[0]);

????}

????/** The system calls this to perform work in the UI thread and delivers

????* the result from doInBackground() */

????protected void onPostExecute(Bitmap result) {

????mImageView.setImageBitmap(result);

????}

????}

????????UI???????????????????????????????????е????????UI????????????????

????????òο?AsyncTask??????????????????????????????????????????????裺

????· ????????generics?Task??????????????????????

????· ????doInBackground()?????????????????????С?

????· ????onPreExecute()??onPostExecute()??onProgressUpdate????UI????е??á?

????· ????doInBackground()?????????????onPostExecute()??????

????· ???????doInBackground()?????????publishProgress()???????÷??????????UI????е?onProgressUpdate()?????????????????????????????????

????· ?????????????????????????????????С?

???????????????????????仯(???????????????)???????????????????????????????????????£????????????????????????ο?Android????????Shelves???????????????μ?????

??????д“?????”????

???????Щ????£????д????????????????????????????????????????“?????”???

????“?????”???????????÷??????????????—???????“??”??Service?е?????????????IBinder??????????е???IBinder????????????÷?????????????????е???????С??????????????????????????????ú????IBinder?????????????????е???????(??y????е?UI???)?????IBinder??????????磬???Service??onBind()???????????Service?????UI????е????????onBind()????????(?????????????RPC??????????)????????????????????????С?????Service???????????????????????????????е???????????IBinder?????????????????IBinder???????????????????????

?????????????Content Provider???????????????????????????????????ContentResolver??ContentProvider?????????????Щ????????????????????????????Щ????????query()?? insert ()?? delete ()?? update () ??getType() ?????Щ????????Content Provider?????????????????????С???????Щ???????в????????????????????????Щ???????????????????

????????????

????Android??????????????(RPC)????????????(IPC)??????????????Activity?????????????????????????????÷?????????????????????????(??????)?????????????????????????????????????ú????????????????Σ???????ò???????????????????????????????????????????????1???????????з????????????????????????Android???????????Щ????????????????д???????????????????????????????????

?????????y???????(IPC)??????????????bindService()???????Service??