在老的版本中是使用Notification
新的版本是使用Notification.Builder
为了兼容性现在使用NotificationCompat.Builder
NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder nb = new NotificationCompat.Builder(Activity1.this);
nb.setDefaults(Notification.DEFAULT_ALL);
nm.notify(1,nb.build());
在高版本的编辑器中使用NotificationCompact.Builder会提示:过时的方法,请不要介意,如果改用Notification.Builder,将会导致在部分手机上无法运行,并且要求修改app的最低编译版本。NotificationCompact.Builder被用在绝大部分app中。