Back to project page barcodescanner.
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.
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; } }