0

How can I handle a user pressing the back button, whilst a ShowcaseView is showing? I want to be able to hide the ShowcaseView when they press back.

As linked from https://github.com/amlcurran/ShowcaseView/issues/376

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Alex Curran
  • 8,818
  • 6
  • 49
  • 55

2 Answers2

1

ShowcaseView allows you to query if it is showing or not. So, if a user presses back and it is showing, simply hide it using Activity#onBackPressed():

@Override
public void onBackPressed() {
    if (sv.isShowing()) {
        sv.hide();
    } else {
        super.onBackPressed();
    }
}
Alex Curran
  • 8,818
  • 6
  • 49
  • 55
0

Try this :

 @Override
    public void onBackPressed() {
        // in if condition check showcaseview is show or hide
        if(isShowcaseViewShow==true) {
           // here hide your showcase view
        }
        else{
              // here perform back action if view already hide
            super.onBackPressed();
        }
    }
Govinda P
  • 3,261
  • 5
  • 22
  • 43