public void sendNotification(Context context, String toast){ Notification notification = new Notification(android.R.drawable.ic_notification_overlay, toast, System.currentTimeMillis()); //建立通知,arg1是通知的图标,arg2是通知的概要,arg3是通知的时间 Intent notificationIntent = new Intent(context, RemoteMp3ListActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 100, notificationIntent, 0); //点击通知,执行startActivityForResult, arg2是requestCode, arg3是执行的intent notification.setLatestEventInfo(context, context.getPackageName(), toast, contentIntent); //通知的具体信息. arg2是通知的标题,arg3是通知的内容,arg4是点击后的执行操做 notification.flags = Notification.FLAG_AUTO_CANCEL; //点击后自动消失 NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //状态栏通知服务 notificationManager.notify( 100, notification);//发送通知, id是为通知设置编号 System.out.println("notification>>>>"); }