Android-TaskStackBuilder.addParentStack使我的应用程序没有响应

Android-TaskStackBuilder.addParentStack使我的应用程序没有响应,android,taskstackbuilder,Android,Taskstackbuilder,因此,我的应用程序将在addParentStack()执行后立即停止响应,并且会出现一个弹出窗口,表示应用程序没有响应,选择等待或关闭它,很快我关闭它,它将显示崩溃或未响应发生之前的前一个活动。 更大的问题是,设备logcat上没有错误消息,因此我无法找到问题的根源 这是我的代码,它是主要活动的一部分 public void addNotif(DetailEvent detailEvent) { Intent resultIntent = new Intent(this, Agenda.

因此,我的应用程序将在addParentStack()执行后立即停止响应,并且会出现一个弹出窗口,表示应用程序没有响应,选择等待或关闭它,很快我关闭它,它将显示崩溃或未响应发生之前的前一个活动。 更大的问题是,设备logcat上没有错误消息,因此我无法找到问题的根源 这是我的代码,它是主要活动的一部分

public void addNotif(DetailEvent detailEvent) {
    Intent resultIntent = new Intent(this, Agenda.class);
//        resultIntent.putExtra("eventName", detailEvent.getEventName());
    resultIntent.putExtra("eventName",detailEvent.getEventName());
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setContentTitle(detailEvent.getEventName());
    builder.setContentText(detailEvent.getEventOpenHour());
    builder.setSmallIcon(R.drawable.ic_launcher);
    builder.setAutoCancel(true);
    builder.setNumber(++numMessages);

    TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
    taskStackBuilder.addParentStack(add_reminder.class);
    //add resultIntent to top of the stack
    taskStackBuilder.addNextIntent(resultIntent);

    PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    notificationManager.notify(0, builder.build());
}
我尝试添加另一个类作为addParentStack参数int,只有一个类可以正常运行,即单事件类,我不知道为什么会发生这种情况

这是我的舱单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.hansel.tapbandung_v00" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.tapbandung.page.Home"
            android:label="@string/app_name" >
        </activity>

        <activity
            android:name="com.tapbandung.page.Profile"
            android:label="@string/title_activity_profile"
            android:parentActivityName=".Host" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.hansel.tapbandung_v00.Host" />
        </activity>
        <activity
            android:name="com.tapbandung.page.Community"
            android:label="@string/title_activity_community" >
        </activity>
        <activity
            android:name="com.tapbandung.page.Event"
            android:label="@string/title_activity_event" >
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>

            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable" />
        </activity>
        <activity
            android:name="com.tapbandung.page.Bussiness"
            android:label="@string/title_activity_bussiness" >
        </activity>
        <activity
            android:name="com.tapbandung.page.single_event"
            android:label="@string/title_activity_single_event"
            android:parentActivityName="com.tapbandung.page.Event" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.Event" />
        </activity>
        <activity
            android:name="com.tapbandung.page.Agenda"
            android:label="@string/title_activity_agenda"
            android:parentActivityName="com.tapbandung.page.Profile" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.Profile" />
        </activity>
        <activity
            android:name=".Host"
            android:label="@string/app_name"
            android:parentActivityName=".Host" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.hansel.tapbandung_v00.Host" />
        </activity>
        <activity
            android:name="com.tapbandung.page.edit_profile"
            android:label="@string/title_activity_edit_profile"
            android:parentActivityName="com.tapbandung.page.Profile" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.Profile" />
        </activity>
        <activity
            android:name="com.tapbandung.page.tapped_events"
            android:label="@string/title_activity_tapped_events"
            android:parentActivityName="com.tapbandung.page.Profile" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.Profile" />
        </activity>
        <activity
            android:name="com.tapbandung.page.single_tapped_event"
            android:label="@string/title_activity_single_tapped_event"
            android:parentActivityName="com.tapbandung.page.tapped_events" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.tapped_events" />
        </activity>
        <activity
            android:name="com.tapbandung.page.login"
            android:label="@string/app_label"
            android:theme="@style/Theme.AppCompat.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.tapbandung.page.signup"
            android:label="@string/title_activity_signup"
            android:theme="@style/Theme.AppCompat.NoActionBar" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.login" />
        </activity>
        <activity
            android:name="com.tapbandung.page.help"
            android:label="@string/title_activity_help"
            android:parentActivityName=".Host" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.hansel.tapbandung_v00.Host" />
        </activity>
        <activity
            android:name="com.tapbandung.page.about"
            android:label="@string/title_activity_about"
            android:parentActivityName=".Host" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.hansel.tapbandung_v00.Host" />
        </activity>
        <activity
            android:name="com.tapbandung.page.add_reminder"
            android:label="@string/title_activity_add_reminder"
            android:parentActivityName="com.tapbandung.page.Agenda" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.tapbandung.page.Agenda" />
        </activity>

    </application>

</manifest>

看起来您使用TaskStackBuilder的方式可能有错误。尝试:

TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
taskStackBuilder.addParentStack(Agenda.class); // Difference is in this line
//add resultIntent to top of the stack
taskStackBuilder.addNextIntent(resultIntent);
addParentStack()调用从清单中读取android:parentActivityName的值,并将所有适当的活动添加到后堆栈中。通常情况下,您希望将其用于当前启动的活动

TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
taskStackBuilder.addParentStack(Agenda.class); // Difference is in this line
//add resultIntent to top of the stack
taskStackBuilder.addNextIntent(resultIntent);