0

我有一个Activity调用带有一些文本的显示通知,单击通知后我想用该文本打开一个新活动,因此我创建了通知:

NotificationManager notManager;
Notification myNot;
PendingIntent pIntent;
Intent intent;


    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Button startBtn = (Button)findViewById(R.id.btnStart);
    tvForNot = (TextView)findViewById(R.id.editText1);
    intent = new Intent(this, BrowserActivity.class);
    intent.putExtra("text", "textToSend");
    pIntent = PendingIntent.getActivity(this, 0, intent, 0);


    OnClickListener startBtnListener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            textToSend = tvForNot.getText().toString();
            notManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            myNot = new Notification(R.drawable.ic_launcher, "title", System.currentTimeMillis());

              func1(textToSend);
            notManager.notify(1,myNot );

        }
    };
    startBtn.setOnClickListener(startBtnListener);


}
public void func1 (String text){
    myNot.setLatestEventInfo(this, "title11", text, pIntent);
}

BrowserActivity我想显示文本但似乎传输的数据有一些问题

public class BrowserActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browser);

    Intent intent = getIntent();

    String fileName = intent.getStringExtra("text");

    TextView textViewDisplay = (TextView) findViewById(R.id.textW);
    textViewDisplay.setText(fileName);

  }
}

文件名始终为空!我的问题在哪里?为什么我无法提取这些数据?

4

0 回答 0