For some reason, I don't get to use android-support-library in my code. In order to perform a Notification that matches Android 4.0 style, I write this:
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);
}
How to control the progress bar in it? The way in developer.google.com is using Notification.Builder
, but Builder is in the android-support-library.
I found another way to do this is
notification.setProgressBar(int viewId, int max, int progress, boolean indeterminate)
But another problem is that it needs a custom notification layout which contains a progress bar. If I use a custom layout, it won't match android 4.0 style.
What can I do now? Please help me, Thanks!