Bug #212
[Login] Crash on screen orientation change
Description
When you are starting BEEM, if you change your screen orientation during the connection process, the application crash.
Some solutions are pointed out on that thread:
http://stackoverflow.com/questions/1111980/how-to-handle-screen-orientation-change-when-progress-dialog-and-background-threa¶
The last solution seems to be the "one"¶
Move the long task to a seperate class. Implement it as a subject-observer pattern. Whenever the activity is created register and while closing unregister with the task class. Task class can use AsyncTask.
Traces of the crash¶
11-16 23:30:50.863: INFO/ActivityManager(71): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.beem.project.beem/.ui.Login }
11-16 23:30:51.033: DEBUG/LOG_AS(22825): BEGIN onCreate.
11-16 23:30:51.073: DEBUG/LOG_AS(22825): END onCreate.
11-16 23:30:51.073: DEBUG/LOG_AS(22825): BEGIN onStart.
11-16 23:30:52.093: DEBUG/LOG_AS(22825): END onStart.
11-16 23:30:52.093: DEBUG/LOG_AS(22825): BEGIN onResume.
11-16 23:30:52.093: DEBUG/LOG_AS(22825): END onResume.
11-16 23:30:52.103: DEBUG/BeemService(22825): ONCREATE
11-16 23:30:52.113: DEBUG/BeemService(22825): ONBIND
11-16 23:30:52.133: DEBUG/LOG_AS(22825): BEGIN onServiceConnected.
11-16 23:30:52.133: DEBUG/LOG_AS(22825): END onServiceConnected.
11-16 23:30:52.223: INFO/ActivityManager(71): Displayed activity com.beem.project.beem/.ui.Login: 1206 ms (total 1206 ms)
11-16 23:30:52.313: DEBUG/BeemService(22825): onStart
11-16 23:30:52.373: INFO/global(22825): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-16 23:30:52.373: INFO/global(22825): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
11-16 23:30:52.583: WARN/System.err(22825): java.security.KeyStoreException: KeyStore jks implementation not found
11-16 23:30:52.583: WARN/System.err(22825): at java.security.KeyStore.getInstance(KeyStore.java:142)
11-16 23:30:52.583: WARN/System.err(22825): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:61)
11-16 23:30:52.593: WARN/System.err(22825): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:1246)
11-16 23:30:52.593: WARN/System.err(22825): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:313)
11-16 23:30:52.593: WARN/System.err(22825): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
11-16 23:30:52.593: WARN/System.err(22825): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)
11-16 23:30:52.723: INFO/WindowManager(71): onOrientationChanged, rotation changed to 1
11-16 23:30:52.723: INFO/WindowManager(71): Setting rotation to 1, animFlags=0
11-16 23:30:52.733: INFO/WindowManager(71): Config changed: { scale=1.0 imsi=0/0 loc=en_IE touch=3 keys=1/1/2 nav=3 orien=2 layout=18}
11-16 23:30:52.813: DEBUG/LOG_AS(22825): BEGIN onPause.
11-16 23:30:52.813: DEBUG/LOG_AS(22825): END onPause.
11-16 23:30:52.813: DEBUG/LOG_AS(22825): BEGIN onStop.
11-16 23:30:52.933: DEBUG/StatusBar(71): updateResources
11-16 23:30:52.983: INFO/global(22825): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-16 23:30:53.003: INFO/global(22825): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
11-16 23:30:53.023: INFO/ActivityManager(71): Stopping service: com.beem.project.beem/.BeemService
11-16 23:30:53.023: DEBUG/LOG_AS(22825): END onStop.
11-16 23:30:53.053: WARN/System.err(22825): org.apache.harmony.security.provider.cert.DRLCertFactory
11-16 23:30:53.073: DEBUG/LOG_AS(22825): BEGIN onCreate.
11-16 23:30:53.243: DEBUG/dalvikvm(22825): GC freed 4704 objects / 348856 bytes in 151ms
11-16 23:30:53.353: DEBUG/LOG_AS(22825): END onCreate.
11-16 23:30:53.363: DEBUG/LOG_AS(22825): BEGIN onStart.
11-16 23:30:53.663: DEBUG/LOG_AS(22825): BEGIN onConnect.
11-16 23:30:53.663: WARN/dalvikvm(22825): threadid=17: thread exiting with uncaught exception (group=0x4001da28)
11-16 23:30:53.663: ERROR/AndroidRuntime(22825): Uncaught handler: thread Thread-19 exiting due to uncaught exception
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): java.lang.NullPointerException
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): at com.beem.project.beem.ui.Login$BeemConnectionListener.onConnect(Login.java:328)
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): at com.beem.project.beem.service.XmppConnectionAdapter$ConnexionListenerAdapter.onConnect(XmppConnectionAdapter.java:368)
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): at com.beem.project.beem.service.XmppConnectionAdapter.triggerAsynchronousConnectEvent(XmppConnectionAdapter.java:243)
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): at com.beem.project.beem.service.XmppConnectionAdapter.connectSync(XmppConnectionAdapter.java:142)
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): at com.beem.project.beem.service.XmppConnectionAdapter$1.run(XmppConnectionAdapter.java:116)
11-16 23:30:53.673: ERROR/AndroidRuntime(22825): at java.lang.Thread.run(Thread.java:1060)
11-16 23:30:53.683: INFO/Process(71): Sending signal. PID: 22825 SIG: 3
11-16 23:30:53.683: INFO/dalvikvm(22825): threadid=7: reacting to signal 3
11-16 23:30:53.763: INFO/dalvikvm(22825): Wrote stack trace to '/data/anr/traces.txt'
11-16 23:30:54.393: DEBUG/LOG_AS(22825): END onStart.
11-16 23:30:54.393: DEBUG/LOG_AS(22825): BEGIN onResume.
11-16 23:30:54.393: DEBUG/LOG_AS(22825): END onResume.
11-16 23:30:54.423: DEBUG/BeemService(22825): ONUNBIND
11-16 23:30:54.443: DEBUG/XMPPConnectionAdapter(22825): closing connection
11-16 23:30:54.453: DEBUG/dalvikvm(22825): threadid=25 wakeup: interrupted
11-16 23:30:54.616: DEBUG/BeemService(22825): ONDESTROY
11-16 23:30:54.623: DEBUG/BeemService(22825): ONCREATE
11-16 23:30:54.623: DEBUG/BeemService(22825): ONBIND
11-16 23:30:54.653: DEBUG/LOG_AS(22825): BEGIN onServiceConnected.
11-16 23:30:54.653: DEBUG/LOG_AS(22825): END onServiceConnected.
11-16 23:30:54.853: DEBUG/BeemService(22825): onStart
11-16 23:30:54.893: INFO/global(22825): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-16 23:30:54.893: INFO/global(22825): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
11-16 23:30:54.983: WARN/System.err(22825): java.security.KeyStoreException: KeyStore jks implementation not found
11-16 23:30:55.013: WARN/System.err(22825): at java.security.KeyStore.getInstance(KeyStore.java:142)
11-16 23:30:55.033: WARN/System.err(22825): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:61)
11-16 23:30:55.033: WARN/System.err(22825): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:1246)
11-16 23:30:55.033: WARN/System.err(22825): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:313)
11-16 23:30:55.043: WARN/System.err(22825): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
11-16 23:30:55.043: WARN/System.err(22825): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)
11-16 23:30:55.173: INFO/Process(22825): Sending signal. PID: 22825 SIG: 9
11-16 23:30:55.203: INFO/WindowManager(71): WIN DEATH: Window{435d6220 com.beem.project.beem/com.beem.project.beem.ui.Login paused=false}
11-16 23:30:55.213: INFO/WindowManager(71): WIN DEATH: Window{435e60f8 com.beem.project.beem/com.beem.project.beem.ui.Login paused=false}
11-16 23:30:55.243: INFO/ActivityManager(71): Process com.beem.project.beem (pid 22825) has died.
11-16 23:30:55.243: WARN/ActivityManager(71): Scheduling restart of crashed service com.beem.project.beem/.BeemService in 5000ms
11-16 23:30:55.603: DEBUG/dalvikvm(71): GC freed 4519 objects / 229968 bytes in 275ms
11-16 23:30:55.633: INFO/WindowManager(71): Setting rotation to 0, animFlags=0
11-16 23:30:55.653: INFO/WindowManager(71): Config changed: { scale=1.0 imsi=0/0 loc=en_IE touch=3 keys=1/1/2 nav=3 orien=1 layout=18}
11-16 23:30:55.673: INFO/WindowManager(71): Config changed: { scale=1.0 imsi=0/0 loc=en_IE touch=3 keys=1/1/2 nav=3 orien=1 layout=18}
11-16 23:30:55.903: WARN/UsageStats(71): Unexpected resume of com.android.launcher while already resumed in com.beem.project.beem
11-16 23:30:55.923: DEBUG/StatusBar(71): updateResources
11-16 23:30:55.953: INFO/WindowManager(71): Config changed: { scale=1.0 imsi=0/0 loc=en_IE touch=3 keys=1/1/2 nav=3 orien=1 layout=18}
11-16 23:30:56.073: WARN/InputManagerService(71): Got RemoteException sending setActive(false) notification to pid 22825 uid 10038
11-16 23:30:57.923: DEBUG/dalvikvm(71): GC freed 4733 objects / 217888 bytes in 231ms