Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7559829
  • 博文数量: 961
  • 博客积分: 15795
  • 博客等级: 上将
  • 技术积分: 16612
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-07 14:23
文章分类

全部博文(961)

文章存档

2016年(1)

2015年(61)

2014年(41)

2013年(51)

2012年(235)

2011年(391)

2010年(181)

分类: Android平台

2015-11-26 11:13:29


点击(此处)折叠或打开

  1. package org.lxh.demo;
  2. import android.app.Activity;
  3. import android.app.Notification;
  4. import android.app.NotificationManager;
  5. import android.app.PendingIntent;
  6. import android.os.Bundle;
  7. public class MyNotificationDemo extends Activity {
  8.     @Override
  9.     public void onCreate(Bundle savedInstanceState) {
  10.         super.onCreate(savedInstanceState);         // 父类方法
  11.         super.setContentView(R.layout.main);                 // 默认布局管理器
  12.         NotificationManager notificationManager = (NotificationManager) super
  13.                 .getSystemService(Activity.NOTIFICATION_SERVICE);    // 取得系统服务
  14.         Notification notification = new Notification(    // 实例化对象
  15.                 R.drawable.pic_m,    // 信息图标
  16.                 "来自MLDN的消息。",     // 信息提示
  17.                 System.currentTimeMillis());    // 显示时间
  18.         PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
  19.                 super.getIntent(),         // 取得Intent
  20.                 PendingIntent.FLAG_UPDATE_CURRENT);    // 取得PendingIntent
  21.         notification.setLatestEventInfo(this, "魔乐科技",        // 信息标题
  22.                 "北京魔乐科技软件学院()",     // 信息内容
  23.                 contentIntent);    // 待发送的Intent
  24.         notificationManager.notify("MLDN",         // 设置信息标签
  25.                 R.drawable.pic_m,     // 设置图标
  26.                 notification);    // 发送信息
  27.     }
  28. }
030907_PendingIntent.ppt
阅读(1945) | 评论(0) | 转发(0) |
0

上一篇:Service

下一篇:发送广播

给主人留下些什么吧!~~