<-- Android/Java --->private NotificationManager mNotifyManager;private NotificationCompat.Builder build;final int id = 101;private class Download extends AsyncTask<Void, Integer, Integer> { @Override protected void onPreExecute() { super.onPreExecute(); // Displays the progress bar for the first time. build.setProgress(100, 0, false); mNotifyManager.notify(id, build.build()); } @Override protected void onProgressUpdate(Integer... values) { // Update progress build.setProgress(100, values[0], false); mNotifyManager.notify(id, build.build()); super.onProgressUpdate(values); } @Override protected Integer doInBackground(Void... params) { //......... FileOutputStream f = new FileOutputStream(new File(rootFile, arg0[1])); InputStream in = c.getInputStream(); byte[] buffer = new byte[1024]; int len1 = 0; float conLen = c.getContentLength(); float total = 0; while ((len1 = in.read(buffer)) > 0) { f.write(buffer, 0, len1); total += len1; publishProgress((int) (total * 100 / conLen)); } f.close(); return result; } @Override protected void onPostExecute(Integer result) { super.onPostExecute(result); Log.e(TAG,"in PostExecute"); build.setContentText("Download complete"); // Removes the progress bar build.setProgress(0, 0, false); mNotifyManager.notify(id, build.build()); } }}问题每个认为工作正常,但当我在postExecute 通知不更新任何人都知道我哪里出错了?
添加回答
举报
0/150
提交
取消