StrictMode confusion - how is it not?

My problem:

12-18 17: 05: 03.336: DEBUG / StrictMode (2112): violation of the StrictMode rules; ~ duration = 2073 ms: android.os.StrictMode $ StrictModeDiskReadViolation: policy = 23 violation = 2

From factory method

12-18 17: 05: 03.336: DEBUG / StrictMode (2112): at android.graphics.BitmapFactory.decodeFile (BitmapFactory.java:299)

Then in my code

12-18 17: 05: 03.336: DEBUG / StrictMode (2112): with blah.ImageCache.getFromCache (ImageCache.java:248)

12-18 17: 05: 03.336: DEBUG / StrictMode (2112):
  in blah2 $ LoaderThread $ 1.handleMessage (blah.java:63)

Important snip-its

the LoaderThread class extends HandlerThread {

public Handler mHandler;

public LoaderThread (string name) {super (name); }

@Override  public void onLooperPrepared() {   mHandler = new Handler() {    public void handleMessage (Message msg) {     Bitmap = ImageCache.getInstance(). GetFromCache ((String) msg.obj, ImageCache.USE_DISK);    }   };  } }

getFromCache ImageCache

bitmap = BitmapFactory.decodeFile(fLoc);

, , . ? HandlerThread ...

LoadThread onCreate (bundle),

LoaderThread loader = LoaderThread ( "imgLoader" )

loader.start();

loader.mHandler.dispatchMessage(loader.mHandler.obtainMessage(..));

, getInstance,

public static synchronized ImageCache getInstance() {

if (_instance == null) {   _instance = new ImageCache();  }  return _instance; }

+3
1

, ...

loader.mHandler.dispatchMessage(loader.mHandler.obtainMessage(args..));

loader.mHandler.sendMessage(loader.mHandler.obtainMessage(args..));

, - , , .

+3

Source: https://habr.com/ru/post/1781069/


All Articles