关键代码:
private void Notific(ChatMsg msg) {
NotificationManager nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification n = new Notification(android.R.drawable.stat_notify_chat,
msg.getText(), System.currentTimeMillis());
n.flags = Notification.FLAG_AUTO_CANCEL;
Intent i = new Intent(context, ChatActivity.class);
Bundle notiextras = new Bundle();
notiextras.putString("state", "initnoti");
notiextras.putString("myname", myname);
notiextras.putString("myid", myid);
notiextras.putString("otherid", msg.getOtherid());
notiextras.putString("myip", msg.getMyip());
notiextras.putString("otherip", msg.getOtherip());
notiextras.putString("date", msg.getDate());
notiextras.putString("name", msg.getName());
notiextras.putString("text", msg.getText());
i.putExtras(notiextras);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(context, 10, i, 0);
n.setLatestEventInfo(context, "你来消息了!", msg.getText(), contentIntent);
n.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_ALL;
nm.notify(100, n);
Log.v("TextID", msg.getText());
}
if(intent!=null){
Log.v("extrasID", extras.toString()+""+myid);
Log.v("extrasID", extras.getString("state")+extras.getString("name"));
if(extras.getString("state").equals("initnoti")){
ChatMsg msg = new ChatMsg(myip,
otherip,
extras.getString("name"),
extras.getString("date"),
extras.getString("text"),
R.layout.example_list_say_he_item);
list.add(msg);
talkView.setAdapter(new ChatMsgViewAdapter(ChatActivity.this,list));
Log.v("ID",  extras.getString("otherip")+"  "+msg.getOtherip()+"  "+msg.getMyip());
myip = msg.getMyip();
otherip = msg.getOtherip();
Log.v("ID", "initnoti"+"  "+msg.getText()+"  "+extras.getString("text"));
}
第一次跳转时notiextras.putString("text", msg.getText());设的只是多少,Log.v("ID", "initnoti"+"  "+msg.getText()+"  "+extras.getString("text"));打印的就是多少,但是第二次时,Log.v("ID", "initnoti"+"  "+msg.getText()+"  "+extras.getString("text"));打印的还是第一次的值,为嘛啊android