0
     @Override
    public void onStart(Intent intent, int startId) {
        // TODO Auto-generated method stub
        super.onStart(intent, startId);
        Toast.makeText(this, "Service started", Toast.LENGTH_SHORT).show();
        final String str=intent.getStringExtra("str");
        Log.v("debugging", str);

NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Intent i = new Intent(Myservice.this, Display.class);
PendingIntent pi = PendingIntent.getActivity(Myservice.this, 0, i, 0);
Notification n = new Notification(R.drawable.ic_launcher,str, System.currentTimeMillis());
n.setLatestEventInfo(Myservice.this,"New message for you: ", str, pi);
nm.notify(1,n);
            }

现在我想将“str”即数据显示到另一个 xml 中的 textview 中。我怎样才能做到这一点?

4

2 回答 2

1

做这样的事情:

Intent i = new Intent(Myservice.this, Display.class);
i.putExtras("str_key", str);

Display Activity得到str这样的:

String strValue = getIntent.getExtras().getString("str_key"); 
于 2013-09-24T12:11:12.603 回答
0

唯一的方法是创建 Activity,它会在用户点击通知项目后打开。

于 2013-09-24T12:08:04.993 回答