Android中Notification值传到Activity获取不到

zilei 发布于 2012/11/14 13:41
阅读 4K+
收藏 0

1.在Notification里面定义一个值

           Intent intent = new Intent(MainActivity.this, NotifyActivity.class);

            PendingIntent pi = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);

            Bundle bundle = new Bundle();
            bundle.putString("id","123456");
            intent.putExtras(bundle);

            Notification notify = new Notification();
            notify.icon = R.drawable.ico_dog;
            notify.tickerText = title;
            notify.when = System.currentTimeMillis();
            notify.defaults = Notification.DEFAULT_SOUND;
            notify.setLatestEventInfo(MainActivity.this, "最新通知", title, pi);
            notify.vibrate = new long[]{0, 50, 100, 150};
            notify.contentIntent = pi;
            notify.flags = Notification.FLAG_AUTO_CANCEL;
            NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

            nm.notify(0x1123, notify);


NotifyActivity里面这样写获取的id的值为NULL 是为什么

         Intent intent = getIntent();
        Bundle data = intent.getExtras();
        String id  = data.getString("id");

求解!!!!!!!!


      


加载中
0
平凡简单
平凡简单
改成

 Intent intent = new Intent(MainActivity.this, NotifyActivity.class);

 Bundle bundle = new Bundle(); 
            bundle.putString("id","123456"); 
            intent.putExtras(bundle); 

            PendingIntent pi = PendingIntent.getActivity(MainActivity.this, 0, intent, 0); 


           
0
z
zilei
嗯 已经解决 
返回顶部
顶部