android - Do variables retain values on orientation change? -


i know when change device landscape portrait , vice versa, oncreate method called. has been cause of problems me.

say have database holds downloads performed. plan on making splash screen dao object convert data objects , put them vector<downloadtask>. happen on asynctask's doinbackground().
onpostexecute splash screen start new activity.

all fine far except when have handle orientation change.
new acitivity after splash screen start timer responsible scheduling downloads. started in oncreate. downloadtask implement runnable threads.

when download on or abruptly stopped, thread supposed tell scheduler , decrease number of threads running simultaneously. cap number of simultaneous downloads.

so, if timing right (or wrong) such orientation change , fninishing of thread line together, what happen timer ? null ?

when orientation changes, variables reset default value ?
also, how prevent orientation change ?? games do

when orientation changes, variables reset default value ?

if activity level variables yes return default values since activity destroyed , recreated each time. avoid either save variables in finish() each time messy since don't know when might happen (but there ways around that). specify in manifest.xml handle these changes adding

android:configchanges="orientation"  

to <activity> tags in manifest. in docs, don't recommend think cover butts. , haven't had problems far. keep activity being destroyed.

also, how prevent orientation change ??

you can in manifest adding like

android:screenorientation="portrait" 

to <activity> tag activities wish have orientation.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -