In my project it keeps crashing due to the VM budget being exceed. The pictures that I am using are all very small but supposedly they keep filling up the VM. I was working through eclipse and notice 2 instances where it gave me the following errors.
This Handler class should be static or leaks might occur (com.quickreaction.BT_screen_menuButtons.2) BT_screen_menuButtons.java /BT_activity_root/src/com/quickreaction line 1091 Android Lint Problem
When I follow the two links this is the source code that it brings me too.
Handler downloadScreenDataHandler = new Handler(){
@Override public void handleMessage(Message msg){
if(JSONData.length() < 1){
hideProgress();
showAlert(getString(R.string.errorTitle), getString(R.string.errorDownloadingData));
}else{
parseScreenData(JSONData);
}
}
};
And..
private Handler buttonImageHandler = new Handler() {
public void handleMessage(Message msg){
//BT_debugger.showIt(activityName + ":buttonImageHandler setting background image for button.");
//msg.what will equal the index of the button images array...
//set the drawable...
Drawable d;
//we may need to round the image...
if(buttonCornerRadius > 0){
d = buttonImages.get(msg.what);
//we have a drawable, our rounding method needs a bitmap...
Bitmap b = ((BitmapDrawable)d).getBitmap();
b = BT_viewUtilities.getRoundedImage(b, buttonCornerRadius);
//convert it back to a drawable...
d = new BitmapDrawable(b);
}else{
d = buttonImages.get(msg.what);
}
buttonSquares.get(msg.what).setBackgroundDrawable(d);
buttonSquares.get(msg.what).invalidate();
} };
I have been reading on stack overflow about making the handler static or weak but don't know how. Any ideas