1.问题
推送通知,设置打开方式为打开指定Activity,如何在activity中获取到推送相关参数
2.解决方案
打开指定Activity时,在该Activity的onCreate()中调用如下代码获取指定参数:
- [backcolor=transparent]Intent[backcolor=transparent] intent [backcolor=transparent]=[backcolor=transparent] getIntent[backcolor=transparent]();
- [backcolor=transparent]// 通知标题
- [backcolor=transparent]String[backcolor=transparent] title [backcolor=transparent]=[backcolor=transparent] intent[backcolor=transparent].[backcolor=transparent]getStringExtra[backcolor=transparent]([backcolor=transparent]"title"[backcolor=transparent]);
- [backcolor=transparent]// 通知内容
- [backcolor=transparent]String[backcolor=transparent] summary [backcolor=transparent]=[backcolor=transparent] intent[backcolor=transparent].[backcolor=transparent]getStringExtra[backcolor=transparent]([backcolor=transparent]"summary"[backcolor=transparent]);
- [backcolor=transparent]// 通知额外参数
- [backcolor=transparent]String[backcolor=transparent] extraMap [backcolor=transparent]=[backcolor=transparent] intent[backcolor=transparent].[backcolor=transparent]getStringExtra[backcolor=transparent]([backcolor=transparent]"extraMap"[backcolor=transparent]);