[android-developers] Re: Honeycomb screenOrientation not working

I do have a stack trace, it crashed in the onCreate method when
calling setContentView with a ResourcesNotFoundException. This seems
to indicate that it was trying to load the landscape xml layout, which
of course doesn't exist since it's supposed to always be portrait and
I didn't make a landscape layout file.

I do use onSaveInstanceState, but I don't think that's applicable
here, it crashes right on startup according to the user.

Perhaps Honeycomb always loads the landscape layout first and then
destroys it and loads the portrait according to the manifest property?

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.molskness.loadplanner/
com.molskness.loadplanner.LoadPlanner}: android.content.res.Resources
$NotFoundException: Resource ID #0x7f030000
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1736)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1752)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3997)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource
ID #0x7f030000
at android.content.res.Resources.getValue(Resources.java:1014)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:
2039)
at android.content.res.Resources.getLayout(Resources.java:853)
at android.view.LayoutInflater.inflate(LayoutInflater.java:389)
at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:
224)
at android.app.Activity.setContentView(Activity.java:1771)
at com.molskness.loadplanner.LoadPlanner.onCreate(LoadPlanner.java:
107)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1048)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1700)
... 11 more

On Apr 2, 12:16 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> On Sat, Apr 2, 2011 at 3:06 PM, Kevin <khant...@hotmail.com> wrote:
> > I have a small app that has the screenOrientation set to "portrait" in
> > the manifest file for the single activity it contains.
>
> > It works fine, except for Honeycomb devices, which users are reporting
> > to me that if they are holding the device in landscape position, the
> > app will crash instead of remaining in portrait mode.
>
> > Do I have to do something extra to keep it forced in portrait, or is
> > it simply not possible to do this in Honeycomb?
>
> This sample project works fine on Honeycomb:
>
> https://github.com/commonsguy/cw-android/tree/master/Rotation/Rotatio...
>
> If you have an app in production, you should be doing something to get
> stack traces (e.g., Android Market console, ACRA, Flurry), which
> should help you determine where things are going wrong.
>
> Bear in mind that having android:screenOrientation="portrait" does not
> stop Android from destroying and recreating your activity. Hence, you
> still need to use onSaveInstanceState() and/or
> onRetainNonConfigurationInstance(), just as you do for any other
> configuration change (dock, locale, etc.).
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_ Version
> 1.9.2 Available!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en