如何获取Notification回传的数据。

ericllzh 2011-01-25 02:33:16

public void SendNotification(String msg,int IconId,Bundle bundle,String title)
{
NotificationManager MyNotiManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notifyIntenet=new Intent(getBaseContext(),test_noti.class);
notifyIntenet.putExtra("sss", "asdf");
notifyIntenet.putExtras(bundle);
notifyIntenet.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent appIn=PendingIntent.getActivity(getBaseContext(), 0, notifyIntenet, PendingIntent.FLAG_UPDATE_CURRENT);
Notification myNoti=new Notification();
myNoti.icon=IconId;
myNoti.tickerText=msg;
myNoti.defaults=Notification.DEFAULT_SOUND;
myNoti.when= System.currentTimeMillis();
myNoti.setLatestEventInfo(getBaseContext(), title, msg, appIn);
MyNotiManager.notify(PublicNotificationId,myNoti);

}


当按了通知栏后,回调到test_noti的public void onCreate(Bundle savedInstanceState)
但savedInstanceState为null 那如何获取我之前传入的数据呢?
...全文
122 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ericllzh 2011-01-25
  • 打赏
  • 举报
回复
找到了。呵呵。
madsky007 2011-01-25
  • 打赏
  • 举报
回复
在onCreate里 getIntent()。 你的数据放在intent里当然要用Intent取

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧