开发者

Android:How create ongoing notification with progress bar?

开发者 https://www.devze.com 2023-03-22 02:46 出处:网络
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 curren

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消