I am trying to show a notification from a BroadcastReceiver in my app, but creating the parent stack is giving me problems. The app just freezes (no exception, just freezes) when I call the following code
Intent notifIntent = new Intent(context, NotificacionesActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addNextIntentWithParentStack(notifIntent); // <- code execution freezes here
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
Which basically is a copy-paste from the android docs here: https://developer.android.com/training/notify-user/navigation#build_a_pendingintent_with_a_back_stack
After a few seconds the output shows this
Thread[3,tid=5321,WaitingInMainSignalCatcherLoop,Thread*=0xf005cc00,peer=0x16940088,"Signal Catcher"]: reacting to signal 3
Wrote stack traces to '[tombstoned]'
and then starts spamming
Background concurrent copying GC freed 87185(5MB) AllocSpace objects, 0(0B) LOS objects, 16% free, 30MB/36MB, paused 223us total 101.944ms
I've looked it up and seems that a tomstone trace should be saved somewhere in /data, but I cant find anything there, I think the log never gets saved. The activity has the parentActivityName declared in the manifest.
<activity
android:name=".activity.NotificacionesActivity"
android:parentActivityName=".activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
/>
The notification shows up if I dont create the pending intent so I'm pretty sure that the code above is the one causing trouble. I've tried on Api 28 and 29 (android 9 & 10), uninstalling the app, and even creating a new virtual device, the result is the same, funny thing is that this code was once working, and now it just doesnt.
SOLVED It seems my mainActivity had itself as parentActivityName, so creating a stack was causing a recursive loop lol.