0

I have an app that spans a dozen activities and I want all activities to respond the same to a few pre-set gestures. I'm wondering if I need to code the GestureDetector/GestureOverlay into each activity? This approach seems silly. I was thinking if it is possible to have a single gesture class that can be responsible for all the different activities. Am I thinking on a correct path?

BTW, I'm very new to Android.

Thanks in advance. Michael

MikeC
  • 223
  • 1
  • 4
  • 15

2 Answers2

0

Try the links it may help you

Fling gesture detection on grid layout

gesture detection

and the following link

Community
  • 1
  • 1
Janmejoy
  • 2,721
  • 1
  • 20
  • 38
  • Thanks for the links. I did look into those and got a rough idea of how gesture works. My other question was how could I write the code once and have it applied to my many activities in the same app. I'm not doing fragments but full screen activities and each of which needs to respond to the same gesture. – MikeC Jan 18 '13 at 09:15
  • k let me think i will get back to you – Janmejoy Jan 18 '13 at 09:18
0

You can do the following

  1. Register to activity lifecycle callbacks
  2. Once you get the callback for onActivityCreated, replace the Window.Callback with your own version of WindowCallback which implements Window.Callback.
  3. Save the Actual activity Window.Callback and you can replace your custom WindowCallback with it on onActivityPaused

You don't have to write your logic in every activity

Uma Sankar
  • 449
  • 1
  • 8
  • 19