发送状态栏通知




private void sendNoti(){
//这是通知,设置图标,即第一次显示的文本,
Notification notification = new Notification(R.drawable.ic_launcher,"通知一下",System.currentTimeMillis());

//有了意图,就有了通知栏点击行为
Intent intents = new Intent(Intent.ACTION_CALL,Uri.parse("tel:1777876876"));

//PendingIntent负责包裹数据
PendingIntent intent = PendingIntent.getActivity(this, 1001, intents, 0);

//负责添加最新的事件信息
notification.setLatestEventInfo(this, "这是标题哦", "这是内容哦", intent);

//添加默认声音
notification.defaults = Notification.DEFAULT_SOUND;

//添加通知栏后的行为,是取消通知显示了
notification.flags = Notification.FLAG_AUTO_CANCEL;

//通知栏管理器
NotificationManager notificationManager= (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

//发出通知
notificationManager.notify(1001, notification);
}