17

I am getting a problem when trying to start an activity using the startActivities() method under TaskStackBuilder sometimes on some phones ( Specifically on Samsung Galaxy S3 - Android 4.3 , Samsung Galaxy S3 Neo - Android 4.4.2)

Below is the code snippet that is used:

TaskStackBuilder stackBuilder = TaskStackBuilder.create(ConfirmAddressActivity.this);
stackBuilder.addParentStack(AddressesActivity.class);

Intent intent = AddressesActivity.createStartingIntent(
    ConfirmAddressActivity.this,
    true, Collections.EMPTY_LIST
);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

stackBuilder.addNextIntent(intent);
stackBuilder.startActivities();

The buggy behaviour, is that after executing stackBuilder.startActivities() it opens a white screen and remains frozen without opening the AddressesActivity. This is not a regular behaviour, it happens sometimes.

The normal behaviour, is that after executing stackBuilder.startActivities() it opens a white screen for (0.5 second - 1 second) then opens the AddressesActivity while the full back stack of that activity had been built correctly. This is the correct behaviour under many devices/platforms. (HTC M9 Android 6.0 , Samsung S2 - Android 4.1.2 , Samsung Galaxy S6 - Android 5.1.1 , LG G4 - Android 5.1.1)

Here is the android manifest snippet that defines the activities:

<activity
    android:name=".activity.account.AccountActivity"
    android:label="My account"
    android:screenOrientation="portrait"
    android:parentActivityName=".activity.DashboardActivity">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".activity.DashboardActivity" />
</activity>

<activity
    android:name=".activity.addresses.AddressesActivity"
    android:label="My addresses"
    android:screenOrientation="portrait"
    android:parentActivityName=".activity.account.AccountActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".activity.account.AccountActivity" />
</activity>

<activity
    android:name=".activity.addresses.ConfirmAddressActivity"
    android:label="Save address"
    android:screenOrientation="portrait"
    android:parentActivityName=".activity.addresses.AddressDetailsActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".activity.addresses.AddressDetailsActivity" />
</activity>

Any help or insight on this problem is much appreciated.

JP Ventura
  • 5,564
  • 6
  • 52
  • 69
Aram Tchekrekjian
  • 925
  • 11
  • 26

0 Answers0