0

I'm really happy if I can show the snackbar before the destination page did load. My current snackbar code here:

final Snackbar snackbar = Snackbar.make(parent_view_chapter, "Redirecting to another page....please wait", Snackbar.LENGTH_SHORT);
snackbar.show();

My expected outcome - right after snackbar dismissed, then the page navigate to my another page.

How I can achieve this? Where should I place the snackbar code? @Override method...is it here should I place the snackbar code?

@Override
public boolean onSupportNavigateUp() {
    onBackPressed();
    return true;
}

@Override
public void onBackPressed() {
    super.onBackPressed();

}

Thanks!

Nere
  • 4,097
  • 5
  • 31
  • 71
  • https://stackoverflow.com/questions/30926380/how-can-i-be-notified-when-a-snackbar-has-dismissed-itself – JoeHz Jan 12 '18 at 21:33
  • The snackbar shown if I click back button or hardware pressed ...then another page will be shown. It seems your link shows right after snackbar callback. – Nere Jan 12 '18 at 21:35
  • see answer below for further explanation – JoeHz Jan 12 '18 at 21:49

1 Answers1

0

The back button will do it's usual thing on the call to super.onBackPressed(), right?

So what would happen if you did NOT call that in your own onBackPressed() event, but instead kicked off your custom snackbar class there? And in the dismissal callback for your snackbar, then called the super.onBackPressed() method.

A fair bit of yak shaving, but I think it might just work. That's why I linked to the custom snackbar implementation above in the comment.

JoeHz
  • 2,136
  • 1
  • 18
  • 29