我想显示一个正在进行的通知。但它仍然显示在通知部分。我为我的通知使用了自定义布局。
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = android.R.drawable.alert_dark_frame;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, "Hi", when);
RemoteViews contentView = new RemoteViews(getPackageName(),
R.layout.custom_notification);
notification.contentView = contentView;
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
notification.contentIntent = contentIntent;
notification.defaults |= Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(0, notification);
}
编辑:你可以看到这张图片,看看我想要做什么。 http://backcountrynavigator.com/wp-content/uploads/screenshots/download_ongoing_notification.png