0

So my app will stop responding soon after the addParentStack() get executed, and there will be a pop up that said app isnt responding, choose to wait or close it, soon I close it, it will show me the previous activity right before the crash or not respondin happen. The bigger problem is, there's no error message on the device logcat so I can't find the root of the problem here's my code which is part of the main activity

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());
}

I tried to add another class as int the addParentStack parameter, only one of the class can run properly,the single_event class, which is I have no idea why that happen...

here's my manifest

<?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>

this was the only log I can get from the device logcat

05-01 22:33:37.836  30470-30479/com.example.hansel.tapbandung_v00 I/art﹕ Thread[5,tid=30479,WaitingInMainSignalCatcherLoop,Thread*=0xb8e68c68,peer=0x12c000a0,"Signal Catcher"]: reacting to signal 3
05-01 22:33:37.836  30470-30479/com.example.hansel.tapbandung_v00 I/art﹕ [ 05-01 22:33:38.036   517:  537 I/Process  ]
Sending signal. PID: 517 SIG: 3
4

1 回答 1

0

看起来您使用 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 的值,并将所有适当的活动添加到后台堆栈。通常,您希望将其用于您当前正在启动的活动。

于 2015-05-11T18:53:20.140 回答