Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.annotation.TargetApi;
import android.app.Activity;

import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.media.ImageReader;
import android.os.Build;
import android.util.DisplayMetrics;

import android.view.Display;

public class Main {
    @TargetApi(Build.VERSION_CODES.KITKAT)
    public static ImageReader createImageReader(Activity c) {
        DisplayMetrics metrics = c.getResources().getDisplayMetrics();
        int density = metrics.densityDpi;
        int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC; //DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
        Display display = c.getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);

        return ImageReader.newInstance(size.x, size.y, PixelFormat.RGB_565, 2);
    }
}