我有一个通过按下按钮启动服务的活动。服务初始化过程中,如果发生错误,会以通知的形式显示该错误,如下:
String tickerText = getString(R.string.init_error);
Notification notification = new Notification(
R.drawable.ic_stat_notify_msg,
tickerText, System.currentTimeMillis());
PendingIntent notificationIntent = PendingIntent.getActivity(
this, 0, new Intent(this, MyServiceActivity.class), 0);
notification.setLatestEventInfo(this,
getText(R.string.init_error_tts_title),
getText(R.string.init_error_tts_text),
notificationIntent);
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
nm.notify(R.string.init_error, notification);
stopSelf();
当通知出现在状态栏中时,我打开通知窗口。然后,当我点击通知时,会启动一个新的 MyServiceActivity 实例......为什么?