Bitmap btm = BitmapFactory.decodeResource(getResources(),
R.drawable.mouse);
Notification.Builder mBuilder = new Notification.Builder(
MsgService.this).setSmallIcon(R.drawable.mouse)
.setContentTitle("1 new message")
.setDefaults( Notification.DEFAULT_SOUND)
.setContentText("这是一个通知。");
mBuilder.setTicker("New SMS");//第一次提示消息的时候显示在通知栏上
mBuilder.setNumber(12);
mBuilder.setLargeIcon(btm);
mBuilder.setAutoCancel(true);//自己维护通知的消失
//构建一个Intent
Intent resultIntent = new Intent(main.this,
Login.class);
//封装一个Intent
PendingIntent resultPendingIntent = PendingIntent.getActivity(
main.this, 0, resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
// 设置通知主题的意图
mBuilder.setContentIntent(resultPendingIntent);
//获取通知管理器对象
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
这行代码出现问题,在最后一行build()下面有一行红色波浪(eclipse)提示出错,不能编译,提示错误原因为:
The method build() is undefined for the type Notification.Builder
求老司机给指一指路,Thx...