/** * For in-app messages that have a preferred orientation, locks the screen orientation and returns * true if the screen is currently in the preferred orientation. If the screen is not currently in * the preferred orientation, returns false. * * <p>Always returns true for tablets, regardless of current orientation. * * <p>Always returns true if the in-app message doesn't have a preferred orientation. * * @param inAppMessage * @return */ boolean verifyOrientationStatus(IInAppMessage inAppMessage) { if (ViewUtils.isRunningOnTablet(mActivity)) { AppboyLogger.d(TAG, "Running on tablet. In-app message can be displayed in any orientation."); return true; } Orientation preferredOrientation = inAppMessage.getOrientation(); if (preferredOrientation == null) { AppboyLogger.d( TAG, "No orientation specified. In-app message can be displayed in any orientation."); return true; } if (preferredOrientation == Orientation.ANY) { AppboyLogger.d( TAG, "Any orientation specified. In-app message can be displayed in any orientation."); return true; } int currentScreenOrientation = mActivity.getResources().getConfiguration().orientation; if (currentOrientationIsValid(currentScreenOrientation, preferredOrientation)) { if (mOriginalOrientation == null) { AppboyLogger.d(TAG, "Requesting orientation lock."); mOriginalOrientation = mActivity.getRequestedOrientation(); mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); } return true; } return false; }