Start a new topic

Orientation change while ArchitectView is still loading leads to crash

Orientation change while ArchitectView is still loading leads to crash


Hi,
I have encountered the following problem in the application I am developing. If device is rotated while the architect view is still loading it results to a crash. Here are 2 stack traces:

On Nexus S and Galaxy Note:

java.lang.NullPointerException
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2491)
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2507)
at android.webkit.WebViewClassic.loadUrl(WebViewClassic.java:2500)
at android.webkit.WebView.loadUrl(WebView.java:768)
at com.wikitude.architect.ArchitectWebView$2.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

On Galaxy S II:

java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.native_setup(Native Method)
at android.hardware.Camera.<init>(Camera.java:350)
at android.hardware.Camera.open(Camera.java:327)
at com.wikitude.tools.views.CameraPreview.onResume(CameraPreview.java:296)
at com.wikitude.architect.ServiceManager.onResume(Unknown Source)
at com.wikitude.architect.ArchitectView.onResume(Unknown Source)
at com.example.ui.fragments.WikitudeFragment.onResume(WikitudeFragment.java:100)
at android.support.v4.app.Fragment.performResume(Fragment.java:1503)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)

Any suggestions how I can handle this situation better, except disabling orientation changes at all.

Thanks,
Rado

Hi there!

What you could do in this situation is that you suppress that the view is recreated each time an orientation change occurs. 

This can be done by adding the following attribute to the activity declaration of your ArchitectView in the manifest-file:

Sample:

<activity android:name="com.example.YourActivity" 

android:configChanges="screenSize|orientation"></activity>

Hope that helps!

best regards, Markus

 
Login or Signup to post a comment