How to show SnackBar before another page destination loaded?

16
January 13, 2018, at 09:36 AM

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!

Answer 1

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.

READ ALSO
What should I specify as --tag parameter in Android SDK's avdmanager?

What should I specify as --tag parameter in Android SDK's avdmanager?

As GUI tools are gone in recent versions of Android SDK and I don't want to use their Android Studio IDE, I'm trying to create virtual device for emulator

20
Notification that apears one a week [on hold]

Notification that apears one a week [on hold]

Please help me I want that in my application will be a notification(notification with a text) that will apear one a week even if the aplication is closedI know that I need a class that will extand BroadCastReceiver

28
Still can't find a solution for “INTERACT_ACROSS_USERS_FULL”

Still can't find a solution for “INTERACT_ACROSS_USERS_FULL”

This issue is related to a previous topicI have an app with a Google Play fragment and it shows blank when opened

29
Icon Launcher Creating Icons Inconstantly Switching Between Round and Square

Icon Launcher Creating Icons Inconstantly Switching Between Round and Square

I have three different applications, all of which I am using the same style to create iconsRight-click mipmap > New > Image Asset

31