title: Android : why do we have to recreate th UI everytime an activity is brought to front?
body: <p>I just started learning android and I am developing an application which uses a socket connection with  a server running on a PC.I am successful in making the connection and able to communicate between the client and server until the "home" button gets pressed or if there is any OnConfigChange events.</p>
  
  <p>I have one activity in the app which has a button (say "connect"). when it is pressed the phone makes a connection with server (all socket codings are done in non-ui thread) and i am changing a TextView (say "status") to "Connected" on successful connection. So when the phone gets rotated or home button is pressed , the app goes hidden. When i go back to my app, the activity starts from the initial stage.All the objects created during the last session is destroyed and lose socket connection.</p>
  
  <p>I just dont understand,</p>
  
  <p>1.Why the activity UI is recreated everytime when it is brought to front?</p>
  
  <p>2.Why cant android just save the state of the activities until user actually wants to exit(by pressing back button)?</p>
  
  <p>3.Why cant android just minimize the app like windows does and go back to last state where user left(so that i have all the objects and )?</p>
  
  <p>4.I have done all socket operation in a non-ui thread and this socket connection was closed once user leave by pressing home button(without pressing back).If so, then how should I save the socket object which i used in the thread during the last instance? </p>
  
  <p>5.Why should we maintain the all the UI changes during "OnPause"? and why cant android itself do the same?(becuase it does have the sate of the app when user leave and i need the exact application state back when user comes back) and bring the same state back when user comes back to the app?</p>
  
  <p>I have been a developer for two years and new to android.Please shed some light on above questions.</p>