I have a monitoring app that displays a set of four parameters as animations (for example, it displays the temperature using a thermometer graphic). I also have one screen which plots all the four parameter values on a chart.
My requirement is this:
I'm wondering if it is possible to provide different functionality based on the orientation. I see 2 options
Activity.onConfigurationChanged()
- but then what? Can i do a setContentView()
at this point? Or, can i launch a different Activity (one which displays the Chart in a separate, lanscape-mode-only Activity)?Application.onConfigurationChanged()
method. But I frankly haven't a clue as to how to proceed with this.Yes you can call setContentView()
inside Activity.onConfigurationChanged()
. You can check orientation and accordingly perform some tasks, i.e. run different code based on orientation.
Normal behaviour is that when orientation changes, system kills Activity and creates a new one. You can prevent this with android:configChanges="orientation"
in you activity manifest. In this case you need to override the onConfigurationChanged(..)
method, which will be called when change happens. See handling runtime changes.