Re: [android-developers] Re: Best approach for onConfiguratinChange()
On Fri, Oct 14, 2011 at 8:07 PM, TreKing treking...@gmail.com wrote: On Fri, Oct 14, 2011 at 4:40 AM, nikki nikhileshsingh...@gmail.comwrote: My confusion shall I handle onConfigurationChange for orientation which will stop android to create a new activity or i should not handle onConfigurationChange and let android do the life cycle process complete. In general, the latter, unless you have a good reason and know what you're doing. Let android handle it should be your first choice. But if creating a new activity is too expensive for your app, you may want to handle the orientation yourself. Since your layout are the same, I guess it won't be very complicate to handle orientation change by yourself. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Best Regards, Ben Lee -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Best approach for onConfiguratinChange()
Let Android handle it. Just create a second layout folder called layout-land and put all your landscape layouts in. The layouts must have the same file name like the layouts in the normal layout folder for portrait mode. Android will pick the right folder to get the layout from. On landscape mode it will take the layouts from the layout-land folder and in portrait mode it will take the layouts from the layout folder. On Oct 14, 11:11 am, nikki nikhileshsingh...@gmail.com wrote: Hi all, I am a bit confused on setting up my screen UI. The point of confusion is I am having similar UI layout file for landscape and portrait. On screen orientation change shall i handle onConfigurationChange or i should let android do the complete activity life cycle and recreating the UI by setContentView(). Please suggest which one is the best optimized approach. Thanks in adavance -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Best approach for onConfiguratinChange()
Thanks Flo for quick reply. In my case the landscape layout files have no changes they are as same as portrait, that's why i haven't created a separate landscape folder for layout(layout_land). So on change of orientation the android will pick the file from layout folder only. My confusion shall I handle onConfigurationChange for orientation which will stop android to create a new activity or i should not handle onConfigurationChange and let android do the life cycle process complete. Thanks On Oct 14, 2:27 pm, Flo florian.bernst...@gmail.com wrote: Let Android handle it. Just create a second layout folder called layout-land and put all your landscape layouts in. The layouts must have the same file name like the layouts in the normal layout folder for portrait mode. Android will pick the right folder to get the layout from. On landscape mode it will take the layouts from the layout-land folder and in portrait mode it will take the layouts from the layout folder. On Oct 14, 11:11 am, nikki nikhileshsingh...@gmail.com wrote: Hi all, I am a bit confused on setting up my screen UI. The point of confusion is I am having similar UI layout file for landscape and portrait. On screen orientation change shall i handle onConfigurationChange or i should let android do the complete activity life cycle and recreating the UI by setContentView(). Please suggest which one is the best optimized approach. Thanks in adavance -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Best approach for onConfiguratinChange()
On Fri, Oct 14, 2011 at 4:40 AM, nikki nikhileshsingh...@gmail.com wrote: My confusion shall I handle onConfigurationChange for orientation which will stop android to create a new activity or i should not handle onConfigurationChange and let android do the life cycle process complete. In general, the latter, unless you have a good reason and know what you're doing. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Best approach for onConfiguratinChange()
There has been a decent amount of conversation on this subject and there's no right answer. Regardless of which way you pick, make sure you understand the pros and cons. If you let Android do the work for you, make sure you understand that your application can be killed off and restarted at any time just by the user rotating the phone, docking, pulling out a hardware keyboard or game pag, etc.. There are quite a few times this can happen, so it would be best to know when it is going to happen and make sure your application is prepared to deal with it at any time. If you decide to handle the changes yourself with configChanges, you only need to handle the changes that impact your application. If you use the same layout for both portrait and landscape, you don't need to handle rotation changes or hardware keyboard/game pad events. Only catch the ones that will impact your application. Check out the configChanges documentation: http://developer.android.com/guide/topics/manifest/activity-element.html#config Each of the events listed there is a time where Android will stop and restart your application if you let it handle the changes. There may be more that aren't documented there, but those are the major ones. If you decide to handle them yourself, those are also the events you have the option of handling if they impact your application. Again, you will only need to handle the ones that would cause a change in your application, the others can be ignored. Based on an application I wrote that checks all the activities in the system (including the built-in apps), about 50% use configChanges and about 50% let Android handle it (on both tablets and phones), so the choice is up to you. Regardless of which way you pick, make sure to do the necessary testing. Steven Studio LFP http://www.studio-lfp.com On Friday, October 14, 2011 4:40:43 AM UTC-5, nikki wrote: Thanks Flo for quick reply. In my case the landscape layout files have no changes they are as same as portrait, that's why i haven't created a separate landscape folder for layout(layout_land). So on change of orientation the android will pick the file from layout folder only. My confusion shall I handle onConfigurationChange for orientation which will stop android to create a new activity or i should not handle onConfigurationChange and let android do the life cycle process complete. Thanks On Oct 14, 2:27 pm, Flo florian@gmail.com wrote: Let Android handle it. Just create a second layout folder called layout-land and put all your landscape layouts in. The layouts must have the same file name like the layouts in the normal layout folder for portrait mode. Android will pick the right folder to get the layout from. On landscape mode it will take the layouts from the layout-land folder and in portrait mode it will take the layouts from the layout folder. On Oct 14, 11:11 am, nikki nikhiles...@gmail.com wrote: Hi all, I am a bit confused on setting up my screen UI. The point of confusion is I am having similar UI layout file for landscape and portrait. On screen orientation change shall i handle onConfigurationChange or i should let android do the complete activity life cycle and recreating the UI by setContentView(). Please suggest which one is the best optimized approach. Thanks in adavance -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en