FYI: I have a bug open against Android for not respecting the
activity's request to handle orientation changes itself:

http://code.google.com/p/android/issues/detail?id=969


On Oct 30, 7:01 am, Mark Hansen <[EMAIL PROTECTED]> wrote:
> You need to store whatever information determines the state of your
> application, use the following overrides:
>
> @Override
> public void onSaveInstanceState(Bundle savedInstanceState)
> {
>     // example
>    savedInstanceState.putString("someKey", someString);
>
> }
>
> then on the load:
> @Override
> public void onRestoreInstanceState(Bundle savedInstanceState)
> {
>   // example
>   String someString = savedInstanceState.getString("someKey");
>
> }
>
> A side note to this is there is some wackiness that goes on with the
> first install that I never really got an answer too, if you can figure
> it out let me know.. the post is here:
>
> http://groups.google.com/group/android-developers/browse_thread/threa...
>
> Good luck.
>
> On Oct 30, 6:56 am, Imran <[EMAIL PROTECTED]> wrote:
>
> > Haii Alllll...
>
> >   The activity gets restarted when the mode changes form  landscape to
> > portrait or vice-versa
> >    is there any way to stop the activity getting restarted..... help
> > me out guysssss
>
> >    Thanks in advance for any Replays..!!!!!!
>
> > Cheers
> > Imran
>
> > On Oct 25, 1:21 am, Peli <[EMAIL PROTECTED]> wrote:
>
> > > You could use yet another method: :-)
>
> > > Define a textview with id=R.id.text_portrait in yourportraitlayout,
> > > and in thelandscapelayout as R.id.text_landscape.
> > > Now, if findViewById(R.id.text_portrait) returns null, you know that
> > > currently thelandscapelayout is being displayed :-)
>
> > > But seriously, I'm surprised that there are so many ways to obtain the
> > > same information, and I have no idea which would be the preferred
> > > one...
>
> > > Peli
>
> > > On Oct 24, 10:00 pm, ksmith44 <[EMAIL PROTECTED]> wrote:
>
> > > > Right.  I have done that too, and it works great.  The problem is that
> > > > aside from using a different layout, my Activity actually needs to do
> > > > slightly different logic bassed on the orientation, (it builds its
> > > > options menu differently forlandscapethan forportrait), which means
> > > > I need to be able to detect which orientation I am using.
>
> > > > Currently, I am using the Configuration method mentioned above and it
> > > > does seem to work.  But with so many different classes, methods and
> > > > constants available to get theoretically the exact same information, I
> > > > wondered if there was a preferred method.
>
> > > > On Oct 24, 12:39 pm, Mark Hansen <[EMAIL PROTECTED]> wrote:
>
> > > > > Setting this android:screenOrientation="sensor"
>
> > > > > as mentioned above worked perfect.. it switched the view as the phone
> > > > > changed.
>
> > > > > I then only created alternate XML files for the layouts that needed
> > > > > tweaking and it worked like a charm.
>
> > > > > On Oct 24, 2:24 pm, ksmith44 <[EMAIL PROTECTED]> wrote:
>
> > > > > > As a followup, I have now found at least 3 ways do determine the
> > > > > > orientation, all of which use different constants with different
> > > > > > values.
>
> > > > > > * There is the aforementioned Activity.getRequestedOrientation which
> > > > > > uses the ActivityInfo constants whereinlandscape=0 andportrait=1
> > > > > > * Then there is getResources().getConfiguration().orientation which
> > > > > > uses the Configuration constants whereinlandscape=2 andportrait=1
> > > > > > * Then there is
> > > > > > getWindow().getWindowManager().getDefaultDisplay().getOrientation().
> > > > > > I am not sure what constants this is using, but it returns exactly 
> > > > > > the
> > > > > > opposite of the first:landscape=1 andportrait=0
>
> > > > > > There are probably more.  Does anyone know the correct or preferred
> > > > > > method?
>
> > > > > > On Oct 23, 12:40 pm, ksmith44 <[EMAIL PROTECTED]> wrote:
>
> > > > > > > How can you determine the current orientation?  Most of my pages
> > > > > > > rotate just fine, but I have one page on which I actually need to 
> > > > > > > do
> > > > > > > slightly different logic based on the orientation (specifically, I
> > > > > > > want to add additional menu options inlandscape mode).  When I use
> > > > > > > getRequestedOrientation(), I always get back a -1 (UNSPECIFIED).  
> > > > > > > It
> > > > > > > appears as if this method only works if an orientation has been
> > > > > > > requested by the code using setRequestedOrientation.  Is there a
> > > > > > > better way to determine the current orientation?
>
> > > > > > > BTW, thanks hackbod for the gem about ctrl-F12.  I never found 
> > > > > > > that in
> > > > > > > the documentation and had been changing the 
> > > > > > > android:screenOrientation
> > > > > > > var in my manifest file and restarting every time I wanted to 
> > > > > > > test in
> > > > > > > the alternate orientation.- Hide quoted text -
>
> > > > > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to