mProgressnotificationmanager = (notificationmanager) this .getSystemService(Context.NOTIFICATION_SERVICE); CharSequence tickerText = "Download"; mProgressNotification = new Notification(R.drawable.ic_launcher,tickerText,System.currentTimeMillis()); context = this.getApplicationContext(); Intent mNotificationIntent = new Intent(context,ActivityClass.class); PendingIntent mPendingIntent = PendingIntent.getActivity(context,mNotificationIntent,0); //mProgressNotification.flags |= Notification.FLAG_auto_CANCEL; mProgressNotification.flags = mProgressNotification.flags | Notification.FLAG_ONGOING_EVENT; CharSequence Title = "Downloading initializing..."; RemoteVIEws contentVIEw = new RemoteVIEws(getPackagename(),R.layout.noti); contentVIEw.setimageVIEwResource(R.ID.status_icon,R.drawable.ic_launcher); contentVIEw.setTextVIEwText(R.ID.status_text,Title); contentVIEw.setProgressbar(R.ID.status_progress,100,false); mProgressNotification.contentVIEw = contentVIEw; mProgressNotification.contentIntent = mPendingIntent; mProgressnotificationmanager.notify(STATUS_bar_NOTIFICATION,mProgressNotification);
之后在doInBackground中,我实现了我的下载程序,之后我正在更新下载进度,
@OverrIDe protected voID onProgressUpdate(Integer... progress) { super.onProgressUpdate(progress); int mDownloadProgress = progress[0]; // Log.d(TAG,"AsyncTask : download In progress"); CharSequence Title = "filename" +": " + mDownloadProgress + "%"; mProgressNotification.contentVIEw.setTextVIEwText(R.ID.status_text,Title); mProgressNotification.contentVIEw.setProgressbar(R.ID.status_progress,mDownloadProgress,false); mProgressnotificationmanager.notify(STATUS_bar_NOTIFICATION,mProgressNotification); }
它正常工作..正确更新,但问题是,通知栏被绞死.我无法向上通知栏.我想更新通知栏,例如从谷歌市场下载任何应用程序(播放).
谢谢…
解决方法 似乎正在发生的是您正在替换通知,这意味着要显示新通知.您需要做的是更新通知而不是替换它.
看看这个:)
http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating
总结以上是内存溢出为你收集整理的android – 将下载进度条更新为AsynTask的通知区域全部内容,希望文章能够帮你解决android – 将下载进度条更新为AsynTask的通知区域所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)