I have an activity that shows a scrollview with a lot of linearlayouts with
a lot of imageviews and textviews.
This activity must show two columns in my scrollview if the orientation is
landscape, and it must show one column in my scrollview if the orientation
is portrait.
It works fine. I have this code on the onCreate method:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
sw=dm.widthPixels;
sh=dm.heightPixels;
if (sw>sh)
portrait=false;
with that code i can check if the screenorientation is portrait or
landscape, and then, generate one or two columns in my scrollview. So, each
time the user changes the screen orientation, the oncreate get's called
again and check wich is the current screen orientation.
*As i said, it works fine, but here comes the problem:*
This activity shows some buttons for download content from internet using a
AsyncTask that shows a horizontal ProgressBar. If i change the orientation
while i'm downloading the content from internet and showing the
progressBar, then i get a exception like this:
04-11 14:29:22.655: INFO/WindowManager(1086): Setting rotation to 0,
animFlags=0
04-11 14:29:22.678: INFO/ActivityManager(1086): Config changed: { scale=1.0
imsi=310/4 loc=en_US touch=3 keys=2/1/2 nav=2/2 orien=1 layout=34 uiMode=17
seq=75}
04-11 14:29:22.717: INFO/UsageStats(1086): Unexpected resume of com.Magazine
while already resumed in com.Magazine
04-11 14:29:22.780: ERROR/WindowManager(4791): Activity com.Magazine.MainMenu
has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@447a3e68 that was
originally added here
04-11 14:29:22.780: ERROR/WindowManager(4791): android.view.WindowLeaked:
Activity com.Magazine.MainMenu has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@447a3e68 that was
originally added here
04-11 14:29:22.780: ERROR/WindowManager(4791): at
android.view.ViewRoot.<init>(ViewRoot.java:247)
Then, i suposed that i must lock the screen orientation changes when the
user is downloading content and showing the progressbar dialog, and i tryed
it locking and unlocking it with this:
((Activity)
context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
((Activity)
context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
IT WORK'S FINE IF I'M IN PORTRAIT MODE and after i start downloading
something i try to change to landscape, it blocks the change and works
finde. *But if i'm in landscape mode and i press the button for download
the content from internet and i start the progressbar dialog, then i get
this exception, and no need to try to change the orientation to portrait
mode, i get the exception instantly:*
04-11 14:33:52.405: INFO/WindowManager(1086): Setting rotation to 0, animFlags=1
04-11 14:33:52.420: INFO/ActivityManager(1086): Config changed: { scale=1.0
imsi=310/4 loc=en_US touch=3 keys=2/1/2 nav=2/2 orien=1 layout=34 uiMode=17
seq=77}
04-11 14:33:52.444: INFO/UsageStats(1086): Unexpected resume of com.Magazine
while already resumed in com.Magazine
04-11 14:33:52.952: INFO/global(4831): Default buffer size used in
BufferedReader constructor. It would be better to be explicit if an 8k-char
buffer is required.
04-11 14:33:53.342: DEBUG/dalvikvm(4831): GC_FOR_MALLOC freed 15782 objects /
1323968 bytes in 52ms
04-11 14:33:53.358: ERROR/WindowManager(4831): Activity com.Magazine.MainMenu
has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@4490f888 that was
originally added here
04-11 14:33:53.358: ERROR/WindowManager(4831): android.view.WindowLeaked:
Activity com.Magazine.MainMenu has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@4490f888 that was
originally added here
04-11 14:33:53.358: ERROR/WindowManager(4831): at
android.view.ViewRoot.<init>(ViewRoot.java:247)
Why it is working in portrait mode and not when i'm in landscape mode?
what is wrong here?
Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en