Reputation: 401
This may sound familiar, I request everyone to read the issue I am facing. My requirement is straightforward. Android wear already has left-to-right swipe to dismiss the activity. However, all I want to do is detect when this action happens and then log the time in a file. My logging mechanism is ready. However, I am not sure how to get the event of right swipe on a wear activity. Please note that I still want to dismiss the activity but just keep a log of it. my activity is a simple class that extends an AppCompatActivity. I am not using any fragments. I just want to detect when that action happens and log that event and exit the app peacefully. Does GestureDetector on android help in this case?
Upvotes: 2
Views: 2130
Reputation: 7701
It seems you are looking for a GestureListener
, I would implement onScroll
or onFling
and would detect a change in the x-axis.
https://developer.android.com/training/gestures/detector.html
There is also a nice video out there:
Alternatively, you can also check if your Activity
was closed by overriding either onDestroy()
or onPause()
in your Activity
.
Upvotes: 2