标签: async-onprogressupdate

AlertDialog setmessage在Asynctask中不起作用

下面是我的代码我试图通过onProgressUpdate方法显示我在Asyntask中的进度,但它不会显示在警报diaalog中.仅显示初始消息.

 class DownloadFileFromURL extends AsyncTask<String, String, String> {

        private AlertDialog.Builder alert;
        private int progress = 0;
        /**
         * Before starting background thread Show Progress Bar Dialog
         */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            alert = new AlertDialog.Builder(context);
            alert.setTitle("Downloading..");
            alert.setMessage("1");
            alert.setCancelable(false);
            alert.show();
        }

        /**
         * Downloading file in background thread
         */
        @Override
        protected String doInBackground(String... f_url) {
            int count;
            try {
                URL url = new URL(f_url[0]);
                URLConnection conection = url.openConnection();
                conection.connect();

                // this will be useful so that you can show …
Run Code Online (Sandbox Code Playgroud)

android android-asynctask android-alertdialog async-onprogressupdate

2
推荐指数
1
解决办法
1258
查看次数