Code example for OrientationEventListener

Methods: canDetectOrientation, enable

0
	protected void onResume() { 
		if (DEBUG) {
			Log.d(TAG, "onResume()");
		} 
		super.onResume(); 
		if (mMyOrientationEventListener.canDetectOrientation()) {
			Toast.makeText(this, "Can DetectOrientation = Enabling Listener", Toast.LENGTH_LONG).show();
			mMyOrientationEventListener.enable();
		} else { 
			Toast.makeText(this, "Can't DetectOrientation", Toast.LENGTH_LONG).show();
			finish();
		} 
	} 
 
	private int getInitialScreenOrientation() { 
		Display display = getWindowManager().getDefaultDisplay();
		int orientation = display.getOrientation();
 
		if (orientation == Configuration.ORIENTATION_UNDEFINED) {
			orientation = getResources().getConfiguration().orientation;