首页 > 移动平台 > 详细

Android Train—notification通知

时间:2015-08-14 18:35:25      阅读:222      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!