0

I need to implement library that acts like Google's Analytic Tools - count the number of button click events in a activity.

I need to add only one line of code to the Activity (after on create) like :

MyTestLibrarySDK.start(this);

The library need to monitor the number of click events and save that count to a file.

The function is called before setContextView which mean there is no layout or view hierarchy yet.

I've tried to find a way to start a broadcast that notify when the activity is loaded but couldn't find one.

Tyler
  • 17,669
  • 10
  • 51
  • 89

1 Answers1

1

You can create a library that intercepts all touch events in that activity and that will check if the view touched is a button.

Some links that should guide you to the answer:

detecting touch events: How to detect touch events in Android

http://developer.android.com/training/gestures/viewgroup.html

Handling them:

handling touch events in Android when using multiple views/layouts

Detect touch event on a view when dragged over from other view

How to know which View is being touched

Can't get touch event detected on a view and click event detected on a parent view

Community
  • 1
  • 1
JanBo
  • 2,925
  • 3
  • 23
  • 32
  • 1
    I can't override activity function like dispatchTouchEvent() because I need all the work to be from the Library and not to add code to the activity –  Nov 22 '13 at 13:40