android Notification
是显示在手机状态栏上的通知,具有全局效果的通知
时效性不强

步骤:
// 获得系统服务
NotificationManager mNotificationManager
= (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

// 创建一个Notification对象
Notification notification = new Notification(R.drawable.ic_launcher,
"短信来了", System.currentTimeMillis());
// 设置点击事件关联activity
Intent intent = new Intent(this, SecondActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,intent, 0);
// 设置标题跟内容
notification.setLatestEventInfo(this, "小丽", "在么", contentIntent);
// 发送通知
mNotificationManager.notify(0, notification);


// 点击之后,消失
// notification.flags = Notification.FLAG_AUTO_CANCEL;
// 点击之后,不会消失
notification.flags = Notification.FLAG_ONGOING_EVENT;


取消通知:
mNotificationManager.cancel(0);//参数必须是之前发送通知的id

更多相关文章

  1. Android——ImageButton【图片按钮】的点击事件与属性
  2. Android(安卓)中Button点击频率的控制
  3. 点击button然后改变其中文字的颜色
  4. EditText设置不自动获取焦点,点击后才获取,并弹出软键盘
  5. Android(安卓)系统菜单与自定义菜单
  6. Android(安卓)ImageView图片显示点击背景切换
  7. Android一个textview显示多段文本不同颜色并可以响应点击事件
  8. android的listView组件
  9. [Android(安卓)UI界面] 求助大神!selector怎么做到点击后保持某个

随机推荐

  1. android进行录音功能并保存播放
  2. Android异步网络请求框架-Volley
  3. 浅谈android的selector,背景选择器
  4. Android(安卓)动画详解
  5. 【Android】从无到有:手把手一步步教你使
  6. Android(安卓)Binder简介
  7. Android中AppWidget加载流程(一)
  8. Android(安卓)之 ServiceManager与服务管
  9. [置顶] android 实现APK之间的跳转
  10. Android上传图片到服务器,android-async-h