, . sampleSize ( sampleSize - ).
public static Bitmap loadBitmapSafety(int resDrId, Context context){
return loadBitmapSafety(resDrId, 1, context);
}
private static Bitmap loadBitmapSafety(int resDrId, int sampleSize, Context context){
BitmapFactory.Options ops = new BitmapFactory.Options();
ops.inSampleSize = sampleSize;
try {
return BitmapFactory.decodeResource(context.getResources(), resDrId, ops);
} catch (OutOfMemoryError e) {
if (sampleSize == 4)
return null;
return loadBitmapSafety(resDrId, sampleSize +1, context);
} catch (Exception e){
return null;
}
}