When a user clicks on the link, I get the event on the manifest and opens ActivityB. Then this means you're putting ActivityB on top of the stack ... This is expected. What you could do is call finish() on ActivityA just before you open ActivityB. In this way you're removing ActivityA from the stack. When you'll go back from ActivityB then the app will display what was before ActivityA - if it was anything there.
In your case, ActivityA seems to be destroyed by Android system to reclaim resources (memory usually). Or maybe you have Developer Options checked and you have in there Don't keep activities checked.
EDIT: because of below reasonable and fair comment on correctness from @merendica, also the down-voter:
In your ActivityA in onCreate() you know if the activity is recreated or not by checking if Bundle attribute is not-null:
if(savedInstance == null) {
// activity newly created
} else {
// activity re-created either because of screen rotation
// or user returned at some point to this activity
}
So if the activity is recreated, don't call any logic that you're currently using.