简单概述Android通知
举例说明
` Button start_notification;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
start_notification = (Button) findViewById(R.id.bt_fs);
start_notification.setOnClickListener(this);
}public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.bt_fs:NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification( R.mipmap.ic_launcher, "有通知来了", System.currentTimeMillis()); Intent intent = new Intent(this, NotificationActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); notification.setLatestEventInfo(this, "股票大涨", "今日万科的股票停牌,应对恶意收购", pendingIntent); manager.notify(1, notification); break; default: break; }
}`