Strange activity stack behavior when using MapActivity

Posted by AndroidDev on Stack Overflow See other posts from Stack Overflow or by AndroidDev
Published on 2010-04-23T11:43:04Z Indexed on 2010/04/23 11:43 UTC
Read the original article Hit count: 432

Filed under:
|
|

I have the following activity structure in my application

A simple "splash screen" activity is started when the application is fired up (let's call it "Splash"). This activity starts the main activity when the user presses a button (I will call it "Main").

Main can in turn start two activities from the menu. The first activity presents a simple form (let's call this one "Form"), the second is a MapActivity that presents a map (it is called "Map").

Main, Form, and Map are declared exactly the same in the manifest:

<activity android:name="fully qualified activity class"
        android:screenOrientation="landscape"
     android:configChanges="keyboard|keyboardHidden|orientation"
    >
    <intent-filter>
        <action android:name="android.intent.action.DEFAULT" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

When Main is active and I start Form and press "back", Main comes up again. Pressing "back" again brings up "Splash". Nothing strange here.

Now comes the strange part: when I am in Main, start Map, and press "back", Main comes up as expected. But pressing "back" again just restarts Main. A second press on "back" is needed to bring me back to Splash!

So it seems that starting the Map activity somehow results in Main ending up on the activity stack twice while starting the Form activity does not!

Both Form and Map are started like this:

startActivity(new Intent(this, MyActivity.class));

I don not catch the back key in any activity.

Any clues on what is going on or how to debug this?

© Stack Overflow or respective owner

Related posts about android

Related posts about mapview