Igor Karun
Igor Karun

Reputation: 629

Catch all clicks of android application

I need to catch all clicks(buttons only) from all activities of App and put only Log.v("","") method. Target: instrument for small group testing of devices, and actions of users. I have different variants of them:

1)

extends activity implements OnClickListener {
....
@Override
    public void onClick(View arg0) {
....

2)

button1.setOnClickListener() {

....

3) Inside of xml

android:onClick="method"

Need to find at least for 1) and 2) solution.

What solutions I need to use:

1) Create some kind of global activity class with OnClickListener and extend all my activities.

2) Or create handler with some broadcast messages.

3) Any advices ...

Upvotes: 0

Views: 382

Answers (1)

Eurig Jones
Eurig Jones

Reputation: 8543

I think the only way to do this would be to create your own subclass of the Button class which would do your required logging before calling the OnClickListener instances for the buttons.

You would then have to use this subclass implementation instead of the standard Button instances in your xml layouts and/or programmatically created Button instances.

Upvotes: 2

Related Questions