链接:http://jingyan.baidu.com/article/77b8dc7fde875a6175eab641.html
http://www.2cto.com/kf/201502/374946.html
java
public void notification_onclick(View view){ Resources res = Activitywenben.this.getResources(); //1.获取状态栏消息管理器 NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); //3.实现页面跳转,构建意图 Intent intent = new Intent(this,Activitybase.class); //4.获取PendingIntent PendingIntent pendingIntent = PendingIntent.getActivity(this,1,intent,0); //2.构建消息 用Builder构建 方法链调用 Notification nt = new Notification.Builder(this) .setSmallIcon(R.drawable.anniu2) .setContentTitle("这是一条消息通知") .setContentText("这是通知内容:点击打开新的界面") .setContentIntent(pendingIntent) .setTicker("显示在状态栏中的信息") .setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.mm)) .setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .build(); //3.交给管理器发出消息 manager.notify(0,nt); } }