異步任務Java Android
No Comments

更新於 2015-07-10 16:34:11

 public class ExcuteAsyncTaskOperation extends AsyncTask<Void, Integer, String>{

        @Override
        protected void onPreExecute() {
            //執行UI設定
            super.onPreExecute();
        }

        @Override
        protected String doInBackground(Void... params) {
            //進行背景工作,如「Network」,並可轉發值。
            //在迴圈中使用publishProgress((onProgressUpdate引數類別)變數);以傳遞資料。
            //例如publishProgress((int)50);
            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... progress) {
            //設定更新進程條
            //setProgressPercent(progress[0]);
        }

        @Override
        protected void onPostExecute(String result) {
            //結束,更新UI介面
            super.onPostExecute(result);
        }
    }

運行方法

    new ExcuteAsyncTaskOperation().execute();

This entry was posted in Java, Note By Weil Jimmer.

About Weil Jimmer

Hi! Everyone! My name is Weil Jimmer. This is my personal blog. I'm a webmaster of this site. I hope the site will be popular. Now, Let's go! Enjoy gaining more knowledge.
More Details About Me : https://weils.net/profile.php


Leave a message.

Only the first 10 comment will show.