Android: i have a Handler class defined inside my activity and i get the warning "Handler class should be static or leaks might occur" with the following code:
Handler messageHandler = new Handler() {
// @Override
public void handleMessage(Message msg) {
try {
... accessing variables defined at the activity level
... doing something very important
}
super.handleMessage(msg)
}
}
However, the problem is that my message Handler has references to main activity variables, so i cannot make it static. How in my case can i get rid of that warning (in correct manner)?