一般手机上边都有一个状态条,显示电池电量、信号强度、未接来电、短信...Android 的屏幕上方也具有状态条。这里所说的通知,就是在这个状态条上显示通知。

发送通知的步骤如下:
1).获取通知管理器

NotificationManager mNotificationManager = (NotificationManager)     getSystemService(Context.NOTIFICATION_SERVICE); 

2).新建一个通知,指定其图标和标题

int icon = android.R.drawable.stat_notify_chat;long when = System.currentTimeMillis();//第一个参数为图标,第二个参数为标题,第三个为通知时间Notification notification = new Notification(icon, null, when);Intent openintent = new Intent(this, OtherActivity.class);//当点击消息时就会向系统发送 openintent 意图PendingIntent contentIntent = PendingIntent.getActivity(this, 0, openintent, 0);notification.setLatestEventInfo(this, “标题”, “内容", contentIntent);mNotificationManager.notify(0, notification); 

更多相关文章

  1. 【Android】Android(安卓)SurfaceFlinger之BufferQueue
  2. Android软键盘不能正确显示
  3. Android控件显示和隐藏
  4. Android(安卓)SharedPreferences保存登录状态
  5. android shape的使用
  6. Android(安卓)Weekly Notes Issue #232
  7. android应用 小试牛刀 开发自己的应用程序就是这么简单
  8. Android(安卓)Power Management
  9. Android中Activity状态的保存和恢复:onSaveInstanceState和onRest

随机推荐

  1. golang如何编译
  2. golang导出csv乱码解决方法
  3. golang 乱码怎么解决
  4. golang判断字符串是否为空的方法
  5. golang怎么生成随机数
  6. golang 开源吗
  7. golang判断字符串是否数字的方法
  8. golang数组和切片的区别是什么
  9. golang用什么ide
  10. golang中协程和线程的区别是什么?