Android Wear 2.0 on swipe back close the app

910 views Asked by At

I need to know how we can close the application on swipe left in Android Wear 2.0. It's a standalone application.

  1. On swipe left which method we can override(If I want to do any other process)
  2. what is the method for close the application - which we have like on mobile android this.finishAffinity();

Thanks in advance

1

There are 1 answers

4
TofferJ On

For and Activity you don't have to do anything, as stated in the documentation

An activity automatically supports swipe-to-dismiss. Swiping an activity from left to right results in dismissal of the activity, and the app navigates down the back stack.

If you use a Fragment you need to wrap it in a SwipeDismissFrameLayout. For more details about how to do that, or how to handle other edge cases, have a look at the documentation referenced above.