Oreintation After Rotating


#1

I added the code to handle rotation. When the program starts (and this also is an issue as sometimes it starts fine and sometimes I have to toggle device menu to get program to appear), the device (Nexus One using Google API 10) starts out fine. Do a few questions, the I rotate device and that is fine (question comes out correct), but when I rotate back, the screen rotates but the text and buttons are rotated 90 degrees instead of returning to its original position (also including the clock/battery on top is now 90 degrees.) When I rotate again for landscape its fine. It somehow seems to have lost what orientation is proper. The code is the same as you listed. Do you know what could be causing this and what I can do to fix it so when it rotates back it orients correctly?

A second question, when I use Nexus 7 with Google API 18, it refuses to load at all, here is the script from the Android log:
2013-10-06 15:42:44 - chap3-GeoQuiz] ------------------------------
[2013-10-06 15:42:44 - chap3-GeoQuiz] Android Launch!
[2013-10-06 15:42:44 - chap3-GeoQuiz] adb is running normally.
[2013-10-06 15:42:44 - chap3-GeoQuiz] Performing com.burk_gerry.geoquiz.QuizActivity activity launch
[2013-10-06 15:42:45 - chap3-GeoQuiz] Automatic Target Mode: using existing emulator ‘emulator-5554’ running compatible AVD ‘AVD_for_Nexus_7_by_Google’
[2013-10-06 15:42:45 - chap3-GeoQuiz] Uploading chap3-GeoQuiz.apk onto device ‘emulator-5554’
[2013-10-06 15:42:45 - chap3-GeoQuiz] Installing chap3-GeoQuiz.apk…
[2013-10-06 15:42:49 - chap3-GeoQuiz] Success!
[2013-10-06 15:42:49 - chap3-GeoQuiz] Starting activity com.burk_gerry.geoquiz.QuizActivity on device emulator-5554
[2013-10-06 15:42:53 - chap3-GeoQuiz] Device not ready. Waiting 3 seconds before next attempt.
[2013-10-06 15:42:53 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.onRun(Am.java:226)
[2013-10-06 15:42:53 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
[2013-10-06 15:42:53 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.main(Am.java:75)
[2013-10-06 15:42:53 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[2013-10-06 15:42:53 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[2013-10-06 15:42:53 - chap3-GeoQuiz] ActivityManager: at dalvik.system.NativeStart.main(Native Method)
[2013-10-06 15:42:56 - chap3-GeoQuiz] Starting activity com.burk_gerry.geoquiz.QuizActivity on device emulator-5554
[2013-10-06 15:43:01 - chap3-GeoQuiz] Device not ready. Waiting 3 seconds before next attempt.
[2013-10-06 15:43:01 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.onRun(Am.java:226)
[2013-10-06 15:43:01 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
[2013-10-06 15:43:01 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.main(Am.java:75)
[2013-10-06 15:43:01 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[2013-10-06 15:43:01 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[2013-10-06 15:43:01 - chap3-GeoQuiz] ActivityManager: at dalvik.system.NativeStart.main(Native Method)
[2013-10-06 15:43:04 - chap3-GeoQuiz] Starting activity com.burk_gerry.geoquiz.QuizActivity on device emulator-5554
[2013-10-06 15:43:08 - chap3-GeoQuiz] Device not ready. Waiting 3 seconds before next attempt.
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: android.util.AndroidException: Can’t connect to activity manager; is the system running?
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.onRun(Am.java:226)
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.main(Am.java:75)
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[2013-10-06 15:43:08 - chap3-GeoQuiz] ActivityManager: at dalvik.system.NativeStart.main(Native Method)
[2013-10-06 15:43:11 - chap3-GeoQuiz] Starting activity com.burk_gerry.geoquiz.QuizActivity on device emulator-5554
[2013-10-06 15:43:14 - chap3-GeoQuiz] Device not ready. Waiting 3 seconds before next attempt.
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: android.util.AndroidException: Can’t connect to activity manager; is the system running?
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.onRun(Am.java:226)
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.main(Am.java:75)
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[2013-10-06 15:43:14 - chap3-GeoQuiz] ActivityManager: at dalvik.system.NativeStart.main(Native Method)
[2013-10-06 15:43:17 - chap3-GeoQuiz] Starting activity com.burk_gerry.geoquiz.QuizActivity on device emulator-5554
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: Error type 2
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: android.util.AndroidException: Can’t connect to activity manager; is the system running?
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.onRun(Am.java:226)
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: at com.android.commands.am.Am.main(Am.java:75)
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[2013-10-06 15:43:19 - chap3-GeoQuiz] ActivityManager: at dalvik.system.NativeStart.main(Native Method)

and hangs there. Do you know why this is happening with this emulator?


#2

This is a problem on some emulators. I have no earthly idea why it happens on some emulators, but not on others… but it does.

Try using a newer emulator. I usually only see this issue on 2.3 and older AVDs.