i am using a service in order to play background music, and i want to create an on going notification with progress bar ,on status bar, in order to user ca开发者_运维问答n watch the progress of current track. Can somebody help me? Thank you very much ...
Create a custom Notification
and put something like this in your notification_layout.xml file:
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="15dp"
android:id="@+id/notificationLoadingBar"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminate="false"
android:indeterminateOnly="false" />
Keep a reference to your Notification
(make it global) and set the progress using RemoteView
's API.
Sample code:
mNotification.contentView.setProgressBar(R.id.notificationLoadingBar,
max, progress, false);
精彩评论