Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to show the same MainActivity on clicking a RecyclerView item (to load another list).
But when addNextIntentWithParentStack is executed, application freezes and not responding for infinite time. Can anybody tell me the issue with this code?
I am using TaskStackBuilder for enabling Back Stack.

Java
itemView.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View view)  {
                    Context context =  view.getContext();
                    Intent startIntent = new Intent(context, MainActivity.class);
                    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
                    stackBuilder.addNextIntentWithParentStack(startIntent);
                    PendingIntent pendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);

                }
            });


What I have tried:

I tried adding below code instead of addNextIntentWithParentStack. But, still same issue. When I remove addParentStack, It works but not as expected. The issue caused by when I add parent.

Java
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(startIntent);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900