Android 为什么';我的活动中没有打开服务?

Android 为什么';我的活动中没有打开服务?,android,android-intent,service,notifications,Android,Android Intent,Service,Notifications,我的问题是,如果单击通知,它会关闭,但不会打开活动 Vertretungsplan。有什么问题吗 这是我的代码: @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub int auswertungsergebnis = 0; boolean

我的问题是,如果单击通知,它会关闭,但不会打开活动 Vertretungsplan。有什么问题吗

这是我的代码:

@Override
        public int onStartCommand(Intent intent, int flags, int startId) {
            // TODO Auto-generated method stub
            int auswertungsergebnis = 0;
            boolean weekday = checkDay();
            if (weekday == true) {
                auswertungsergebnis = auswerten();
            }
            String ausgabe = ausfaller.toString().replace("[", "").replace("]", "");
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction(ACTION);
            registerReceiver(notifyServiceReceiver, intentFilter);

            // Send Notification
            notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            myNotification = new Notification(R.drawable.ic_stat_gymi,
                    "Notification!", System.currentTimeMillis());
            Context context = getApplicationContext();
            String notificationTitle = "Neue Vertretungsstunden!";
            String notificationText = ausgabe + " fällt heute aus";
            Intent myIntent = new Intent(context, Vertretungsplan.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(
                    getBaseContext(), 0, myIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
            myNotification.defaults |= Notification.DEFAULT_SOUND;
            myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
            myNotification.setLatestEventInfo(context, notificationTitle,
                    notificationText, pendingIntent);

            if (auswertungsergebnis == 1) {
                notificationManager.notify(MY_NOTIFICATION_ID, myNotification);
            }
            return super.onStartCommand(intent, flags, startId);
        }

提前感谢:)

您正在将
Intent.FLAG\u ACTIVITY\u NEW\u TASK
传递到
pendingent.getActivity
-需要将该标志添加到
Intent
本身:

Intent myIntent = new Intent(context, Vertretungsplan.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(
    getBaseContext(), 0, myIntent, 0);