1

I'm currently running into an issue in an ARCore Android app (this is without sceneform). I have an activity that has a fragment that holds the ARCore session object, as well as the OpenGL ES context tied to the surfaceView, and an external C++ class that uses jni to communicate with the Android app.

I am trying to preserve the state of those objects upon orientation change, but there doesn't seem to be a way to save those objects as parcelables inside the Activity's Bundle for recreation after changing to landscape mode.

Given this, I have resorted to using android:configChanges="orientation|screenSize|keyboardHidden"

inside my AndroidManifest.xml file and overriding onConfigurationChanged(); inside my Activity.

I have tried calling a method inside onConfigurationChanged() that calls a method inside a View class that updates its layout manually, but this doesn't seem to work.

Basically what I am trying to do is get my ARCore app to preserve all of its state after changing to landscape orientation, but I have several layout view objects in the app that look very different in Portrait versus Landscape mode. Because the activity is no longer recreating itself, it doesn't automatically load the layout files inside my resources/layout or resources/layout-land folders.

As a more thorough example, I have tried reloading the view files inside my view class, but this doesn't seem to properly update from the existing landscape view to the new portrait view. Oftentimes when I rotate the phone from portrait to landscape, and I call the related updateLandscapeLayout() method, a view inflates but off the view of the screen. It inflates below the bottom of the screen where I can't see it.

How do I properly manually replace views for portrait and landscape at runtime by overriding onConfigurationChanged()?

Soud Kyl
  • 55
  • 5
  • I know this is a very old question but did you manage to find an answer to this? –  Jul 19 '21 at 11:54

0 Answers0