@Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what == 1) { // NotificationManager manager = // (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); // //构建一个通知对象(需要传递的参数有三个,分别是图标,标题和 时间) // Notification notification = new // Notification(R.drawable.ic_launcher,"通知",System.currentTimeMillis()); // Intent intent = new Intent(activity_main.this,activity_chat.class); // PendingIntent pendingIntent = // PendingIntent.getActivity(this,0,intent,0); // // notification.setLatestEventInfo(getApplicationContext(), "位置社交", // "您有新聊天消息,请注意查看", pendingIntent); // notification.flags = Notification.FLAG_AUTO_CANCEL;//点击后自动消失 // notification.defaults = Notification.DEFAULT_SOUND;//声音默认 //// notification.flags |= Notification.FLAG_SHOW_LIGHTS; //// notification.defaults = Notification.DEFAULT_LIGHTS; // notification.ledARGB = Color.BLUE; // notification.ledOnMS =5000; //闪光时间,毫秒 // manager.notify(1, notification);//发动通知,id由自己指定,每一个Notification对应的唯一标志 // //其实这里的id没有必要设置,只是为了下面要用到它才进行了设置 } } }