I'm trying to start an activity and at the same time correctly maintain a backstack to allow the user to use the back button. To do so, I'm following Google's instructions, but am getting nowhere. When I click my button, nothing happens (except the log output). What do I need to do to make this launch the next activity?
mBtnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "click");
Intent intent = new Intent(ProfileSelectActivity.this, PermissionsRequestActivity.class);
PendingIntent pendingIntent =
TaskStackBuilder.create(ProfileSelectActivity.this)
// add all of DetailsActivity's parents to the stack,
// followed by DetailsActivity itself
.addNextIntentWithParentStack(intent)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(ProfileSelectActivity.this);
builder.setContentIntent(pendingIntent);
}
});
It seems to me that there is a missing line at the end. I've tried startActivities();
, startActivity();
among other things, but I'm unsuccessful with all of my attempts.
Thanks for any help.
EDIT
Attempting to implement the suggestion below from njzk2 but I'm still confused. In order to add startActivities()
to the end of the TaskStackBuilder line, I have to remove any assignment to PendingIntent. This is probably OK. However, after the next activity starts, if I hit the back button I just get a white screen.
TaskStackBuilder.create(ProfileSelectActivity.this)
.addNextIntentWithParentStack(intent)
.startActivities();
I also noticed that my onResume
method in the parent activity is not called when returning via the back button, so this could just be a problem of restoring state???