I don't know what your code looks like, so I don't know what you need to modify, butI did some searching through the documentation. I found some stuff on Notifications, ProgressBars, and RemoteViews.
Specifically, in RemoveView, you can update the Progress bar. So combining some of the example code in each link, I get something like this:
public class MyActivity extends Activity {
private static final int PROGRESS = 0x1;
private static final int MAX_PROGRESS = 100;
private int mProgressStatus = 0;
private Handler mHandler = new Handler();
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
//define Notification
//...
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
contentView.setProgressBar(R.id.progress_bar, MAX_PROGRESS, mProgressStatus, false);
notification.contentView = contentView;
// Start file upload in a background thread
new Thread(new Runnable() {
public void run() {
while (mProgressStatus < MAX_PROGRESS) {
mProgressStatus = doWork();
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
contentView.setProgressBar(R.id.progress_bar, MAX_PROGRESS, mProgressStatus, false);
}
});
}
}
}).start();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…