Notification使用实例
来源:互联网 发布:sql删除一个列 编辑:程序博客网 时间:2024/05/16 10:15
- 创建一个Notification的步骤。
思路:①得到NotificationManager的引用;②初始化一个Notification对象;③设置Notification的参数;④使用NotificationManager的notify(int, Notification)方法发出通知。
public void initNotifi() {
String ns = Context.NOTIFICATION_SERVICE;</span>
//得到NotificationManager的引用
mNotificationManager = (NotificationManager) getActivity()
.getSystemService(ns);
//初始化一个Notification对象,并设置参数,闪灯、声音、icon
notification = new Notification();
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.icon = R.drawable.shop;
notification.when = System.currentTimeMillis();
context = getActivity().getApplicationContext(); contentTitle = "简付"; contentText = "买单成功,点击查看!";}</span>
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_maidanimdia:
//使用NotificationManager的notify(int, Notification)方法发出通知。
Intent notificationIntent = new Intent(getActivity(),
CardTxnDetailsActivity.class);
contentIntent = PendingIntent.getActivity(getActivity(), 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentIntent);
mNotificationManager.notify(MAIDAN_ID, notification);
getActivity().finish();
break;
- Notification使用实例
- Notification(四)——Notification完整使用实例详解
- Notification实例
- android简单实例-----------5种Notification的简单使用
- Notification 使用
- Notification使用
- 使用Notification
- Notification 使用
- notification 使用
- Notification使用
- Notification使用
- 使用Notification
- notification使用
- Android Notification实例理解
- IOS Notification通知实例
- Android Notification实例理解
- android Notification 实例
- Android当中Notification实例
- Spark不常用的参数调节
- 蒁葿螄膁膁蚄蚀膀芃蒇罿膀
- STM32的CAN总线过滤器的配置
- 羂莀蚀羈肈膇蕿袁肄莅荿袃
- 螃肈薅薅羈肄薄蚇袁莃薄蝿
- Notification使用实例
- 虿罿芇螀袈膁膀莃薄肁膂葿
- 数据库三大范式详解
- 螂腿薁蚂肀膈芀蒄羆芇莃蚀
- 袄膂节螃蚃肄芈蕿羅肇莃蚈
- 膁薃蚄肃膀芃衿罿艿莅蚂袅
- (二)洞悉linux下的Netfilter&iptables:内核中的ip_tables小觑
- 螂芅蒃螆膇莁薂蚆膀蒆莈羈
- 蚂螃膂芀螅罿肈艿蒄螂羄芈