I have an application that allows you to capture the contents of the screen. However, sometimes I get the null value returned from aquireLatestImage . The documentation says that it will return "null if image data is not available."
I am curious to know which frames cannot be accessed for images?
Edit: from what I can say, most often this happens on LG devices ...
Edit 2: The case I'm running in is the null value returned after it previously returned valid image values. And it keeps returning null values. For non-LG devices, zeros sometimes return. For LG devices, it seems that when it returns one zero, the rest will be zero.
Edit 3: Include some code
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); display.getMetrics(displayMetrics ); ImageReader imageReader = ImageReader.newInstance(displayMetrics.widthPixels, displayMetrics.heightPixels, PixelFormat.RGBA_8888, 2); virtualDisplay = mediaProjection.createVirtualDisplay("NetCountableVirtualDisplay", displayMetrics.widthPixels, displayMetrics.heightPixels, displayMetrics.densityDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, imageReader.getSurface(), null, null);
android
Camhart
source share