在我的项目中,由于超出了 VM 预算,它不断崩溃。我使用的图片都非常小,但据说它们会不断填满虚拟机。我正在通过 eclipse 工作并注意到 2 个实例,它给了我以下错误。
这个 Handler 类应该是静态的,否则可能会发生泄漏 (com.quickreaction.BT_screen_menuButtons.2) BT_screen_menuButtons.java /BT_activity_root/src/com/quickreaction line 1091 Android Lint Problem
当我点击这两个链接时,这也是它带给我的源代码。
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);
}
}
};
和..
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();
} };
我一直在阅读有关使处理程序静态或弱的堆栈溢出,但不知道如何。有任何想法吗