码迷,mamicode.com
首页 > 其他好文 > 详细

关于点击Notification后,获取Notification中的信息

时间:2016-01-01 22:58:04      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

 

在点击Notification之后,通常需要在界面上呈现Notification中的信息。

 

在测试的时候,在Activity中通过getIntent获取到的Intent对象中,总是获取不到想要的信息。

在网上搜索发现,如果使用了相同的Intent,在创建PendingIntent的时候需要设置Flags参数为PendingIntent.FLAG_CANCEL_CURRENT,如下所示。

PendingIntent.getActivity(AtyNotification.this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)

 

如果不是相同的Intent,Flags参数可不设置为PendingIntent.FLAG_CANCEL_CURRENT

   Intent intent2 = new Intent(Intent.ACTION_VIEW);
   intent2.setData(Uri.parse("tel:10086"));
   notification.setContentIntent(PendingIntent.getActivity(AtyNotification.this, 0, intent2, 0));

 

关于点击Notification后,获取Notification中的信息

标签:

原文地址:http://www.cnblogs.com/huanyou/p/5093764.html

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