Thank you so much for your effort. But unfortunatelly that isnt
working with my code. Maybe that's because I am running my activities
in Tabs or one of my activity is the camera. Anyhow, with your
proposed code I am running into same problems as before.
Any ideas left?

Thanks!!!!

On Jul 29, 1:24 pm, Sarwar Erfan <[email protected]> wrote:
> Hi,
> I have tested the proposed code and it works. I have mentioned details
> here:http://erfanonline.blogspot.com/2010/07/android-use-different-orienta...
>
> You can download sample source from there also.
>
> Regards
> Sarwar Erfan
>
> On Jul 29, 4:01 pm, Sarwar Erfan <[email protected]> wrote:
>
> > Hi,
> > The problem is, each timeorientationis changed, Activity is
> > destroyed and recreated (that means onCreate is called, later onStart
> > is called). Now, when you changeorientationinside onCreate, then
> >orientationis changed, activity is recreated again ---> this causes
> > to onCreate to be called again (and again and again ....)
> > onCreate is even called before the Activity is shown on the screen.
>
> > I can think of one way around. Get rid of allorientationchanging
> > codes form onCreate and onStart.
> > Then, before starting an activity, changeorientation(if required)
> > according to the requirement of the activity to be started.
>
> > For example: suppose you need LANDSCAPE for Activity2, then (see how
> > the condition of if changed)
>
> > //---------------
> > if(this.getRequestedOrientation() !=
> > ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
>
> > this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);}
>
> > //Start Activity2 here
> > //---------------
>
> > If you dont want to do as I told above, you need to prevent your
> > activities from being destroyed and recreated whenorientationis
> > changed. Fortunately, that is possible.
> > Go to this 
> > link:http://developer.android.com/reference/android/app/Activity.html#Conf...
> > Quote from the page:
> > [QUOTE]
> > In some special cases, you may want to bypass restarting of your
> > activity based on one or more types of configuration changes. This is
> > done with the android:configChanges  attribute in its manifest. For
> > any types of configuration changes you say that you handle there, you
> > will receive a call to your current activity's
> > onConfigurationChanged(Configuration) method instead of being
> > restarted. If a configuration change involves any that you do not
> > handle, however, the activity will still be restarted and
> > onConfigurationChanged(Configuration)  will not be called.
> > [/QUOTE]
>
> > Regards
> > Sarwar Erfan
>
> > On Jul 29, 3:21 pm, Robert <[email protected]> wrote:
>
> > > Thanks Sarwar for your answer. But when I put this code into the
> > > onStart method. Theorientationwill always be Portrait.
> > > When I discard the if-part, I am getting the same problem as mentioned
> > > above. I realized now that, when the app enters the onStart the
> > >orientationis initally -1(thats why I get the portrait-orientation
> > > with the if-part). When the setrequestedorientation is called the
> > >orientationis 0 (LANDSCAPE), as I requested. And then it is in this
> > > infinite loop and when its now entering the onstart the
> > > requestedorientation is 1 (PORTRAIT). Which is really weird to me.
> > > Should I do anything in theTabActivity!? Any suggestions are very
> > > welcome.
> > > Thanks
>
> > > On Jul 29, 10:46 am, Sarwar Erfan <[email protected]> wrote:
>
> > > > Hi,
> > > > Good day.
>
> > > > Change theorientation(call setRequestedOrientation) inside
> > > > overridden method of onStart, NOT inside onCreate. (do it in both
> > > > Activity1 and Activity2)
>
> > > > Regards
> > > > Sarwar Erfan
>
> > > > On Jul 29, 2:25 pm, Robert <[email protected]> wrote:
>
> > > > > Hello,
> > > > > I have atabactivitywhere my app is running in. One of the tabs needs
> > > > > to have landscapeorientation, assume this is activity2, activity1
> > > > > needs to have portrait-orientation.
>
> > > > > In activity1 I do have code like:
>
> > > > > public void onCreate(Bundle savedInstanceState) {
> > > > >         super.onCreate(savedInstanceState);
> > > > >         if(this.getRequestedOrientation() ==
> > > > > ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
>
> > > > > this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
>
> > > > > }
>
> > > > > And in activity2:
>
> > > > > public void onCreate(Bundle savedInstanceState) {
> > > > >         super.onCreate(savedInstanceState);
> > > > >         if(this.getRequestedOrientation() ==
> > > > > ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
>
> > > > > this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
>
> > > > > }
>
> > > > > So when I now want to change from activity1 to activity2. It seems as
> > > > > my app is in a infinite-loop, it tries to start activity2 again and
> > > > > again, but it doesnt appear. I dont get an exception either!
>
> > > > > Is that some know bug of android or am I doing something wrong. Help a
> > > > > appreciated a lot.
>
> > > > > Thanks
>
>

-- 
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

Reply via email to