new Timer().schedule(new TimerTask(){
@Override
public void run(){
//定时发送一个空消息
handler.sendEmptyMessage(0x123);
}}, 0, 200};
}
//获取系统服务---白拿一个NotificationManager
NotificationManager notificationManager = (NotificationManager)
super.getSystemService(Activity.NOTIFICATION_SERVICE);
//用图片,文字,时间, 创造一个notification
@SuppressWarnings("deprecation")
Notification notification = new Notification(
R.drawable.ic_launcher,
"林森通知你",//通知的时候闪一下的几个字
System.currentTimeMillis()
);
//第三个参数Intent,是notification点击后要做的intent----PendingIntent的意义就是包装一个Intent
PendingIntent pendingIntent = PendingIntent.getActivity
(this, 0, getIntent(), PendingIntent.FLAG_UPDATE_CURRENT);
//拉下来的时候要显示的字,PendingIntent放出notification---设置通知栏的点击事件
notification.setLatestEventInfo(this, "重要新闻", "四川又地震了", pendingIntent);
notificationManager.notify("tag", R.drawable.ic_launcher, notification);