# Error during device orientation

**URL:** https://community.wowza.com/t/error-during-device-orientation/54045
**Category:** Wowza GoCoder SDK
**Created:** [October 8, 2019, 3:47pm UTC](https://community.wowza.com/t/error-during-device-orientation/54045 "2019-10-08T15:47:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)
#### Post date: [October 8, 2019, 3:47pm UTC](https://community.wowza.com/t/error-during-device-orientation/54045/1 "2019-10-08T15:47:11Z")

</div>

Hi.

I have a problem during device orientation.

I use GoCoder SDK in a fragment loaded by an Activity.

I can start the app in portrait mode but the fragment that use the SDK is locked in landscape mode.

If I change the device’s orientation when I click the button that start the fragment I get this error:

2019-10-08 17:38:19.655 4148-4148/it.tim.videolive.pslte E/AndroidRuntime: FATAL EXCEPTION: main Process: it.tim.videolive.pslte, PID: 4148 java.lang.RuntimeException: set display orientation failed at android.hardware.Camera.setDisplayOrientation(Native Method) at com.wowza.gocoder.sdk.api.devices.WOWZCamera.autoDetectOrientation(WOWZCamera.java:1160) at com.wowza.gocoder.sdk.api.devices.WOWZCameraView.doConfigChange(WOWZCameraView.java:1164) at com.wowza.gocoder.sdk.api.devices.WOWZCameraView.onConfigurationChanged(WOWZCameraView.java:1187) at android.app.Application.onConfigurationChanged(Application.java:130) at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:5001) at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:5200) at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:5124) at android.app.servertransaction.ConfigurationChangeItem.execute(ConfigurationChangeItem.java:42) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6806) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

If I click the button in portrait mode and wait the fragment is fully loaded I have no problem.

Same if I click the button with device in landscape mode.

There is a way to intercept the orientation changing during the fragment’s loading?

Thanks in advance

---

<div class="post-metadata">

### Author: ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)
#### Post date: [October 8, 2019, 6:29pm UTC](https://community.wowza.com/t/error-during-device-orientation/54045/2 "2019-10-08T18:29:25Z")

</div>

By default @DarthXander, the live stream will maintain the orientation of the device when the broadcast began. However, there are some settings you can adjust and I will direct you to that documentation.

[https://www.wowza.com/docs/wowza-gocoder-sdk-faq#does-the-sdk-support-switching-between-portrait-and-landscape-orientation-while-streaming-](https://www.wowza.com/docs/wowza-gocoder-sdk-faq#does-the-sdk-support-switching-between-portrait-and-landscape-orientation-while-streaming-)

You can adjust some settings to reflect the following: **same as device** , a **lways landscape, always portrait**.

[https://www.wowza.com/resources/gocodersdk/docs/api-docs-android/?com/wowza/gocoder/sdk/api/configuration/WOWZMediaConfig.html](https://www.wowza.com/resources/gocodersdk/docs/api-docs-android/?com/wowza/gocoder/sdk/api/configuration/WOWZMediaConfig.html)

---

<div class="post-metadata">

### Author: ![DarthXander](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@DarthXander](https://community.wowza.com/u/DarthXander)
#### Post date: [October 9, 2019, 3:29pm UTC](https://community.wowza.com/t/error-during-device-orientation/54045/3 "2019-10-09T15:29:33Z")

</div>

I think to have resolved the problem (but I must do some testing) placing this code in the onDestroy and onBackPressed methods of my fragment.

```auto
try {
    goCoderCameraView.stopPreview();
    goCoderCameraView.clearView();
}

```

catch (Exception e) {}

goCoderCameraView is the WOWZCameraView object that I use in my fragment.

It’s like something remains active in the view after the endBroadcast called in the WOWZBroadcast Object.
