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. Market stats not updated since three days

My download statistics on the Market's publisher page have not been
updated since three days. Anyone noticed the same issue?


2. Market behaving strangely today

Firstly I'm not able to download anything from the markets... the
status just shows 'Starting download' and it just sticks there. This
has been happening for a day or so, and I have two devices on
different networks, so it must be the market and not me.

Also, I have some apps installed which the market doesn't recognize,
it just shows the option to download as normal.

Anyone else? What's going on?


3. Theme.Translucent.NoTitleBar.Fullscreen and fullscreen?

4. How to access and change settings for the phone and email accounts

5. ! WTA//鈩igh importance

6. better keyboard nga berfungsi

7. Google apps-for-android code samples