出于某种原因,我不能在我的代码中使用 android-support-library。为了执行与 Android 4.0 风格匹配的通知,我这样写:
private void noti() {
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.ic_launcher;
CharSequence text = "Notification Text";
CharSequence contentTitle = "Notification Title";
CharSequence contentText = "Sample notification text.";
long when = System.currentTimeMillis();
Intent intent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
Notification notification = new Notification(icon,text,when);
notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
notificationManager.notify(1, notification);
}
怎么控制里面的进度条呢?developer.google.com 中的方式是 using Notification.Builder
,但 Builder 在 android-support-library 中。
我发现另一种方法是
notification.setProgressBar(int viewId, int max, int progress, boolean indeterminate)
但另一个问题是它需要一个包含进度条的自定义通知布局。如果我使用自定义布局,它将与 android 4.0 样式不匹配。
我现在能做什么?请帮助我,谢谢!