Initially I had a single layout for my activity and used the following attributes to avoid re-creating the activity and thus sending a new request to the database on screen rotation:
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize
Later I decided to use an alternative layout for landscape mode. The problem was my app never switched to that alternative layout because of the above mentioned attributes. So, I removed them, and it started switching between landspace/portrait layout, but now I'm facing the same issue that the activity sends a new request to the DB on each recreate.
How can I use alternative layouts and avoid the activity being recreated?
protected override void OnCreate(Bundle savedInstanceState)
{
AllLinesFromBatch = new List<WhseActivLine>();
Orders = new List<WhseActivHeader>();
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.NextOrder);
var backBtn = FindViewById<Button>(Resource.Id.buttonBack);
backBtn.Click += BackBtn_Click;
var startBtn = FindViewById<Button>(Resource.Id.buttonStart);
startBtn.Enabled = false;
startBtn.Click += StartBtn_Click;
notificationsArea = FindViewById<TextView>(Resource.Id.notificationsNextorder);
notificationsArea.Text = string.Empty;
var dsHeaders = Utility.WsHueckmann.GetDataWhseActivHeaders(PickActivity.CheckedZonesList.ToArray(), LoginActivity.User);
....other code.....
}
In the above code the line
var dsHeaders = Utility.WsHueckmann.GetDataWhseActivHeaders(PickActivity.CheckedZonesList.ToArray(), LoginActivity.User)
is where the call to DB takes place.