Do variables retain values on orientation change?
I know that when you change the device from landscape to portrait and vice
versa, the onCreate method is called. That has been a cause of some
problems for me.
Say I have a database which holds the downloads that are to be performed.
I plan on making a splash screen where a DAO object will convert this data
into objects and put them into a Vector<DownloadTask>. This will happen on
an AsyncTask's doInBackground().
onPostExecute the splash screen will start a new Activity.
All is fine so far except when I have to handle orientation change.
The new Acitivity after the splash screen will start a Timer which is
responsible for scheduling the downloads. This will be started in
onCreate. The DownloadTask all implement Runnable so they are threads.
When the download is over or abruptly stopped, the thread is supposed to
tell this to the scheduler and decrease the number of threads running
simultaneously. This is to cap the number of simultaneous downloads.
So, if the timing is right (or wrong) such that the orientation change and
the fninishing of the thread line up together, what will happen to the
Timer ? Will it be null ?
When orientation changes, are the variables reset to their default value ?
Also, how do I prevent orientation change ?? Like some games do
No comments:
Post a Comment