Why are onCreate() onStart() etc. called when handset orientation is changed?

by steff » Wed, 16 Dec 2009 02:20:17 GMT

Sponsored Links
 Hi everyone,

I got my hands on Android which is really fun. But at some point I
don't seem to understand the concept. I've got a Main class which
reads like this:

public class Main extends Activity implements SensorEventListener
{ ... }

in the onCreate(...)  I set the layout to
and add an OnTouchEvent Listener to the sole View in main.xml:
myView.setOnTouchListener(new OnTouchListener() {
                        public boolean onTouch(View v, MotionEvent event) {...

As you can see I also implemented a SensorEventListener which is used
if required. All works fine so far.

But my problem is this (at this point my misunderstanding kicks in):
whenever I rotate the device the onCreate(), onStart() etc. methods
are called, causing my app to act as if it just started. Furthermore,
I feel unable to implement an onSizeChanged(int w, int h, int oldw,
int oldh) { ... } Listener.

Can anyone please explain where my error in reasoning is? I am working
on a tiny app which is more or less done, except for the just
mentioned bug(s). Maybe I got it all wrong but it does what it is
supposed to do (i.e. sending touch positions and accelerometer data
over the network via UDP).

Thanks for any help.


Other Threads

1. How to configure SDK emulator to start with english instead of japanese?

Hello all
I'm new to Android development and have just startet playing with the SDK.

One thing that is annoying is that the emulator always start with Japanese
I have found out how to fix this by going into settings and remove all the
Japanese stuff, but this is time consuming since I have to do it every time
I start the emulator.

Can someone help me change the startup settings for the emulator?

Thanks in advance



2. Switching Tab Activities from Sub Activities.

I came to a solution to this problem. The idea is to send a
TabSwitcher Object with the Intent to the child classes which can then
use this to switch between tabs, this can be extended to finishing and/
or creating activities into the tab from the sub activities. Check out
the blog and the source code link is attached to the blog.



3. How to read pdf file into my customize android app

4. Is it possible to determine a input method in application

5. Visit Installed App Details Page on Android 2.2

6. JIT compilation on Dalvik VM

7. Accelerometer not working when screen turns off