case 1:
Bundle bundle = msg.getData();
int size  = bundle.getInt("size");
     notification.contentView.setProgressBar(R.id.pb_status, fileDownload.getFileSize(),size, false);
     notificationManager.notify(R.drawable.download_downloading, notification);
case 2:

System.out.println("文件下载完成!  ++++++++++++++++++++++++++==");
  notification = new Notification(R.drawable.download_downloading,"文件下载完成!",System.currentTimeMillis());
  notificationManager.notify(R.drawable.download_downloading, notification);
notificationManager.cancel(R.drawable.download_downloading);
执行case 1 更新进度条. 下完成后. 执行case  2  出现空指针异常   .求解 .  

解决方案 »

  1. notification = new Notification(R.drawable.download_downloading,"文件下载完成!",System.currentTimeMillis());
    这段代码出问题了. 似乎不能使用new Notification .重新设置Notification的属性就行了 正确的 notification.icon = R.drawable.icon;
      notification.tickerText = "文件下载完成 !";
      notification.when =  System.currentTimeMillis();
      notificationManager.notify(R.drawable.download_downloading, notification);
    notificationManager.cancel(R.drawable.download_downloading);
      

类似问题 »