Reputation: 4959
Is there a main handler for android applications. For example, can i override the main event handler such that when the events come in i can log the events and then pass them to the original main handler to be processed? is there something similar for Java on android?
I know this is possible on Mac OS x its called method swizzling
My_mainHandler(event e){
//log event e
log(e)
//send event to main handler to be processed
maineventhandler(e)
}
Upvotes: 0
Views: 184
Reputation: 11439
Is there a main handler for android application?
Kind of. Use Looper.getMainLooper(); and the create a new Handler passing that looper.
can i override the main event handler
As far as I know, without getting into the source of Android, you can't. Again, I just recommend capturing the Looper and using that instead. I'm not sure if you will be able to see the events though....
EDIT:
This is for capturing your application looper. I don't think you can capture the OS's looper.
Handler handler = new Handler(Looper.getMainLooper()) {
@Override public void handleMessage(Message msg) {
// Do stuff
}
}
Upvotes: 1