Android Open Source - barcodescanner Display Utils






From Project

Back to project page barcodescanner.

License

The source code is released under:

Apache License

If you think the Android project barcodescanner listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.dm7.barcodescanner.core;
//w  ww .jav  a2s. c  om
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;

public class DisplayUtils {
    public static Point getScreenResolution(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point screenResolution = new Point();
        if (android.os.Build.VERSION.SDK_INT >= 13) {
            display.getSize(screenResolution);
        } else {
            screenResolution.set(display.getWidth(), display.getHeight());
        }

        return screenResolution;
    }

    public static int getScreenOrientation(Context context)
    {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();

        int orientation = Configuration.ORIENTATION_UNDEFINED;
        if(display.getWidth()==display.getHeight()){
            orientation = Configuration.ORIENTATION_SQUARE;
        } else{
            if(display.getWidth() < display.getHeight()){
                orientation = Configuration.ORIENTATION_PORTRAIT;
            }else {
                orientation = Configuration.ORIENTATION_LANDSCAPE;
            }
        }
        return orientation;
    }

}




Java Source Code List

me.dm7.barcodescanner.core.BarcodeScannerView.java
me.dm7.barcodescanner.core.CameraPreview.java
me.dm7.barcodescanner.core.CameraUtils.java
me.dm7.barcodescanner.core.DisplayUtils.java
me.dm7.barcodescanner.core.ViewFinderView.java
me.dm7.barcodescanner.zbar.BarcodeFormat.java
me.dm7.barcodescanner.zbar.Result.java
me.dm7.barcodescanner.zbar.ZBarScannerView.java
me.dm7.barcodescanner.zbar.sample.FormatSelectorDialogFragment.java
me.dm7.barcodescanner.zbar.sample.MainActivity.java
me.dm7.barcodescanner.zbar.sample.MessageDialogFragment.java
me.dm7.barcodescanner.zbar.sample.ScannerActivity.java
me.dm7.barcodescanner.zbar.sample.ScannerFragmentActivity.java
me.dm7.barcodescanner.zbar.sample.ScannerFragment.java
me.dm7.barcodescanner.zbar.sample.SimpleScannerActivity.java
me.dm7.barcodescanner.zbar.sample.SimpleScannerFragmentActivity.java
me.dm7.barcodescanner.zbar.sample.SimpleScannerFragment.java
me.dm7.barcodescanner.zxing.ZXingScannerView.java
me.dm7.barcodescanner.zxing.sample.FormatSelectorDialogFragment.java
me.dm7.barcodescanner.zxing.sample.MainActivity.java
me.dm7.barcodescanner.zxing.sample.MessageDialogFragment.java
me.dm7.barcodescanner.zxing.sample.ScannerActivity.java
me.dm7.barcodescanner.zxing.sample.ScannerFragmentActivity.java
me.dm7.barcodescanner.zxing.sample.ScannerFragment.java
me.dm7.barcodescanner.zxing.sample.SimpleScannerActivity.java
me.dm7.barcodescanner.zxing.sample.SimpleScannerFragmentActivity.java
me.dm7.barcodescanner.zxing.sample.SimpleScannerFragment.java