There is *no* reason to make the layout portrait-only. If you have one layout, just put it in layout/ and leave it at that. If there are other restrictions globally on the kinds of screens your device will work on then express that elsewhere (setting a forced screen orientation, saying you don't support normal/large screens, etc).
On Sat, Apr 2, 2011 at 1:21 PM, Kevin <[email protected]> wrote: > Yeah I can see why it's a good idea to always have a default. In the > case of this app though, I don't know if a generic layout would work > for both layout and portrait, it would usually extend off the screen > in one direction or another. I suppose I could put it in a scrolling > layout for the default. > > Thanks for the help. > > On Apr 2, 1:14 pm, Mark Murphy <[email protected]> wrote: > > Well, that's a risky setup anyway. *Always* have one of *every* > > resource in the default resource set (e.g., one of every layout in > > res/layout/). Override as needed. > > > > > > > > > > > > > > > > > > > > On Sat, Apr 2, 2011 at 4:03 PM, Kevin <[email protected]> wrote: > > > That ID is the layout file, but it's in /res/layout-port/ I don't have > > > a /res/layout/ or /res/layout-land/. So it must not be looking in / > > > res/layout-port/ even though it's supposed to always use the portfolio > > > orientation... > > > > > It works fine on 2.2 and lower, I don't get it. > > > > > On Apr 2, 12:48 pm, Mark Murphy <[email protected]> wrote: > > >> Have you looked in your R.java file (assuming you have the exact > > >> R.java file corresponding with the production code) to see what > > >> resource has the ID of 0x7f030000? > > > > >> If your layout is in res/layout/, Android will always find it. > > > > >> On Sat, Apr 2, 2011 at 3:43 PM, Kevin <[email protected]> wrote: > > >> > 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 <[email protected]> wrote: > > >> >> On Sat, Apr 2, 2011 at 3:06 PM, Kevin <[email protected]> > 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 > [email protected] > > >> > To unsubscribe from this group, send email to > > >> > [email protected] > > >> > For more options, visit this group at > > >> >http://groups.google.com/group/android-developers?hl=en > > > > >> -- > > >> 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 > [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > > > -- > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

