Skip to content

Instantly share code, notes, and snippets.

View SuhailMehta's full-sized avatar

Suhail Mehta SuhailMehta

View GitHub Profile
@SuhailMehta
SuhailMehta / OrientationListener.java
Last active August 21, 2017 16:50
Detect screen orientation in portrait locked screen for android
public abstract class OrientationListener extends OrientationEventListener {
public static final int CONFIGURATION_ORIENTATION_UNDEFINED = Configuration.ORIENTATION_UNDEFINED;
private volatile int defaultScreenOrientation = CONFIGURATION_ORIENTATION_UNDEFINED;
public int prevOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
private Context ctx;
private ReentrantLock lock = new ReentrantLock(true);
public OrientationListener(Context context) {
super(context);