持续更新------------------
回调函数是protected权限,重写时还是protected导致的错误,解决办法是用public;比如Activity的onDestroy()函数;
同样的函数用support-vX包中的,导致错误,解决办法不用support-vX包中的函数,比如SearchView;
资源回收导致的问题如:在onCreate()中有
bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.flower);
imageView.setImageBitmap(bitmap);[ 1]
回调函数中:
BitmapDrawable tmp = (BitmapDrawable)
imageView.getDrawable();
if (!tmp.getBitmap().isRecycled())
{
tmp.getBitmap().recycle();
}
Bitmap bitmap2 = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
imageView.setImageBitmap(bitmap2);
这时就会出错;bitmap别强制回收了;
解决办法只要保证bitmap不被回收即可;[ 1]处改为
bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.flower);
bitmap 1= BitmapFactory.decodeResource(this.getResources(), R.drawable.flower);
imageView.setImageBitmap(bitmap1);这样bitmap1会被回收而bitmap不会被回收;
函数/this使用位置不对的问题:
WallpaperManager.getInstance(this);如果放在类的初始块位置,会导致程序崩溃;
因为初始化块的执行早于构造器的执行。也就是说,如果该函数放在初始化块的话,this还没有
指向实例,它是空指针;同样的如果你在初始化块执行了一个实例方法也会导致程序崩溃;