Hy,
I have an activity that is binding/unbinding to a service in OnStart()/OnStop()
.
If I open a link from a list ( that opens in a browser) while holding the phone horizontally the application crashes.
I would like to mention that the activity is restricted in the manifest to portrait mode and is singleTop
.
I get the following error:
ERROR/AndroidRuntime(9864): FATAL EXCEPTION: main
java.lang.NullPointerException
at roboguice.service.RoboService.onConfigurationChanged(RoboService.java:92)
at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:3618)
at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:3746)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
I noticed that if the service is still bound when the orientation is changed then the app crashes.
My questions:
- Is there a bug in RoboGuice 2.0 or I'm just using it wrong?
- Is there a way to unbind the service before orientation changes ?
- If for another activity I have the binding/unbinding in
OnCreate()/OnDestroy()
and I want to keep that binding until the activity is destroyed how do I do that , in these circumstances ?