1

I have no idea of this is actually possible, but i want the device to have different activities for landscape and portrait. I have a listview, and of all the items in my listview i have the coordinates. So i thought, it would be nice if you put your device in landscape, and show a mapview with icons placed on the locations of the items.

I know you can create different layouts for different orientations, but only creating an mapview and using that as landscape layout wont do the trick i guess. Is there something possible in an equivalent way for activities? I couldn't find it, so probably not.

Else i think this might work: I thought myself of a switch in the activity: on portrait --> do this and load this layout, on landscape --> do that and use the other layout. But this would only work once if put in the oncreate. But than the orientationlistener would do the trick. Anyone knows of this is possible?

Jasper
  • 2,389
  • 4
  • 25
  • 40
  • 4
    Just my two cents on the matter; I don't think this would be a very good experience. If the user accidentally rotates the screen, they're suddenly looking at something very different. Seems confusing. – Krylez Aug 02 '12 at 08:50
  • try adding different layouts for landscape and portrait view – Shruti Aug 02 '12 at 08:52

2 Answers2

1

There is a method in activity lifecycle

public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);                
            // Check the Orientation of Device
            // Start Other Activity
    ...
    ...
    ...

}

you can use this method to change the activity if the device orientation changes.

Adeel Pervaiz
  • 1,336
  • 10
  • 11
0

IMHO we can't use 2 different activities here, but there is a way,

please check out how to detect orientation dynamically here, check-orientation-on-android-phone

once you are through this, you can include code for landscape mode here in the same activity.

Community
  • 1
  • 1
monish_sc
  • 146
  • 6