码迷,mamicode.com
首页 > 移动开发 > 详细

Android Train—notification通知

时间:2015-08-14 18:36:05      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

Notification

extends Object
implements Parcelable

java.lang.Object

   ?
android.app.Notification

Public Constructors:   比较常用的构造方法

Notification(int icon, CharSequence tickerText, long when)

Constructs a Notification object with the information needed to have a status bar icon without the standard expanded view.

Public Methods

void setLatestEventInfo(

Context context,

CharSequence contentTitle,

CharSequence contentText,

PendingIntent contentIntent)

Sets the contentView field to be a view with the standard "Latest Event" layout.

 

Creating a Notification
int icon = R.drawable.notification_icon;        // icon from resources
CharSequence tickerText = "Hello";              // ticker-text
long when = System.currentTimeMillis();         // notification time
Context context = getApplicationContext();      // application Context
CharSequence contentTitle = "My notification";  // expanded message title
CharSequence contentText = "Hello World!";      // expanded message text

Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

// the next two lines initialize the Notification, using the configurations above
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

Android Train—notification通知

标签:

原文地址:http://www.cnblogs.com/plant/p/4730551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!