定制用户自己的信息通知类型
2012-03-30 14:18
295 查看
package src.com;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.widget.RemoteViews;
public class NotifyService extends Service {
private static final int HELO_ID = 1;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
// Use with getSystemService(String) to retrieve a NotificationManager for informing the user of background events.
String ns = Context.NOTIFICATION_SERVICE;
//得到提醒管理对象
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
CharSequence tickerText = "记得缴钱";
//String tickerText = "记得缴钱";
long when = System.currentTimeMillis();//Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC.
//Notification A class that represents how a persistent notification is to be presented to the user using the NotificationManager.
Notification notification = new Notification(R.drawable.ic_launcher, tickerText, when);
/*
* 定制用户信息通知的版型
* 利用RemoteViews创建一个view来指定给contentView
*/
RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.toast_robot);
notification.contentView = contentView;
//Context context = getApplicationContext();//Return the full application info for this context's package.
//CharSequence contentTitle = "Libro来的提醒";
//CharSequence contentText = "点击进入缴费清单";
Intent notificationIntent = new Intent(this, BillList.class);
//getActivity得到PendingIntent实例,即将进行某种操作
//getActivity(Context context, int requestCode, Intent intent, int flags)
//Retrieve a PendingIntent that will start a new activity, like calling Context.startActivity(Intent).
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
//setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
//notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.contentIntent = contentIntent;
//notify(int id, Notification notification)
//Post a notification to be shown in the status bar.
mNotificationManager.notify(HELO_ID, notification);////发出状态栏通知
}
}
不一定非要用到setLatestEventInfo方法。
不过要自定义用户的pendding下拉列表中的用户提醒的话,可以采用RemoteViews
package src.com;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.widget.RemoteViews;
public class NotifyService extends Service {
private static final int HELO_ID = 1;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
// Use with getSystemService(String) to retrieve a NotificationManager for informing the user of background events.
String ns = Context.NOTIFICATION_SERVICE;
//得到提醒管理对象
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
CharSequence tickerText = "记得缴钱";
//String tickerText = "记得缴钱";
long when = System.currentTimeMillis();//Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC.
//Notification A class that represents how a persistent notification is to be presented to the user using the NotificationManager.
Notification notification = new Notification(R.drawable.ic_launcher, tickerText, when);
/*
* 定制用户信息通知的版型
* 利用RemoteViews创建一个view来指定给contentView
*/
//getPackageName()指向了applicatio下的包
RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.toast_robot);
notification.contentView = contentView;
//Context context = getApplicationContext();//Return the full application info for this context's package.
//CharSequence contentTitle = "Libro来的提醒";
//CharSequence contentText = "点击进入缴费清单";
Intent notificationIntent = new Intent(this, BillList.class);
//getActivity得到PendingIntent实例,即将进行某种操作
//getActivity(Context context, int requestCode, Intent intent, int flags)
//Retrieve a PendingIntent that will start a new activity, like calling Context.startActivity(Intent).
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
//setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
//notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.contentIntent = contentIntent;
//notify(int id, Notification notification)
//Post a notification to be shown in the status bar.
mNotificationManager.notify(HELO_ID, notification);////发出状态栏通知
}
}
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.widget.RemoteViews;
public class NotifyService extends Service {
private static final int HELO_ID = 1;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
// Use with getSystemService(String) to retrieve a NotificationManager for informing the user of background events.
String ns = Context.NOTIFICATION_SERVICE;
//得到提醒管理对象
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
CharSequence tickerText = "记得缴钱";
//String tickerText = "记得缴钱";
long when = System.currentTimeMillis();//Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC.
//Notification A class that represents how a persistent notification is to be presented to the user using the NotificationManager.
Notification notification = new Notification(R.drawable.ic_launcher, tickerText, when);
/*
* 定制用户信息通知的版型
* 利用RemoteViews创建一个view来指定给contentView
*/
RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.toast_robot);
notification.contentView = contentView;
//Context context = getApplicationContext();//Return the full application info for this context's package.
//CharSequence contentTitle = "Libro来的提醒";
//CharSequence contentText = "点击进入缴费清单";
Intent notificationIntent = new Intent(this, BillList.class);
//getActivity得到PendingIntent实例,即将进行某种操作
//getActivity(Context context, int requestCode, Intent intent, int flags)
//Retrieve a PendingIntent that will start a new activity, like calling Context.startActivity(Intent).
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
//setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
//notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.contentIntent = contentIntent;
//notify(int id, Notification notification)
//Post a notification to be shown in the status bar.
mNotificationManager.notify(HELO_ID, notification);////发出状态栏通知
}
}
不一定非要用到setLatestEventInfo方法。
不过要自定义用户的pendding下拉列表中的用户提醒的话,可以采用RemoteViews
package src.com;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.widget.RemoteViews;
public class NotifyService extends Service {
private static final int HELO_ID = 1;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
// Use with getSystemService(String) to retrieve a NotificationManager for informing the user of background events.
String ns = Context.NOTIFICATION_SERVICE;
//得到提醒管理对象
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
CharSequence tickerText = "记得缴钱";
//String tickerText = "记得缴钱";
long when = System.currentTimeMillis();//Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC.
//Notification A class that represents how a persistent notification is to be presented to the user using the NotificationManager.
Notification notification = new Notification(R.drawable.ic_launcher, tickerText, when);
/*
* 定制用户信息通知的版型
* 利用RemoteViews创建一个view来指定给contentView
*/
//getPackageName()指向了applicatio下的包
RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.toast_robot);
notification.contentView = contentView;
//Context context = getApplicationContext();//Return the full application info for this context's package.
//CharSequence contentTitle = "Libro来的提醒";
//CharSequence contentText = "点击进入缴费清单";
Intent notificationIntent = new Intent(this, BillList.class);
//getActivity得到PendingIntent实例,即将进行某种操作
//getActivity(Context context, int requestCode, Intent intent, int flags)
//Retrieve a PendingIntent that will start a new activity, like calling Context.startActivity(Intent).
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
//setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
//notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.contentIntent = contentIntent;
//notify(int id, Notification notification)
//Post a notification to be shown in the status bar.
mNotificationManager.notify(HELO_ID, notification);////发出状态栏通知
}
}
相关文章推荐
- Android平台 用户可以根据自己输入的地址下载网络上的图片和网页信息
- 用户可修改自己信息的限制
- 第九章:用户自己建立数据类型(结构体)
- 自己动手,定制VISTA/WIN7的OEM信息
- moodle 3.0 限制用户修改自己信息
- ROS:定制自己的消息类型msg
- “System.NotSupportedException”类型的异常在 System.Data.Entity.dll 中发生,但未在用户代码中进行处理 其他信息: 在 LINQ to Entitie
- discuz X2.5自己写代码,获取当前登录的用户信息
- c语言解析系列(6)用户建立自己的数据类型
- 在主函数中提示用户输入用户名和密码。另写一方法来判断用户输入是否正确。该方法分别返回一个bool类型的登录结果和和一个string类型的登录信息。如登录成功,返回true及“登录成功”,若登录失败则返回false及“用户名错误”或“密码错误”(使用out参数)
- 安卓完成一个应用,用户可以根据自己输入的地址下载网络上的图片和网页信息
- 分享知识-快乐自己:自定义struts2类型转换的全局与局部错误信息。
- SQL SERVER 列出所有用户表,字段名,主键,类型,长度,小数位数等信息(转)
- VS如何定制自己的模板信息
- YTUOJ-计算该日在本年中是第几天(用户自己定义类型)
- 根据ID集合查询符合某种类型的用户信息,并按其他类型分类
- Oracle查询表创建时间,更新时间,用户信息,表类型,查询表结构等
- 技术曝光:电信网络诈骗,是网络银行自己造成,网络媒体却一直使用媒体信息引导推卸到用户身上,是一个很大错误.根源在网络银行本身.
- WSS3SDK之:在内容类型中定制信息
- [求助]小程序获取除了自己以外的用户的信息