I am new to working with the Twitter4J library and am running into a bit of a problem in Android. So I currently have an activity stack like A,B,C,D. From activity D I login to twitter using twitter4J. When the twitter login redirects back to my activity, it creates a new instance of the activity on the stack. The stack becomes A,B,C,D,TwitterLogin,D. I need my application to return to the state A,B,C,D so selecting the back button will pop activity D and bring activity C to the front.
Does anyone have any suggestions on how I would achieve this?
adding Intent.FLAG_ACTIVITY_CLEAR_TOP to the intent that you launch in order to start Activity D should do the trick. Something like this:
Intent i = new Intent(this, ActivityD.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);