Injectview screen rotation issue

46 views
Skip to first unread message

Xtine

unread,
Mar 17, 2010, 6:26:11 AM3/17/10
to roboguice
Hi,
I get an exception when I rotate my phone:

E/AndroidRuntime( 912): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 912): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.icemobile.albertheijn/
com.icemobile.albertheijn.ui.activity.recipes.RecipeSpinnerActivity}:
java.lang.NullPointerException: Can't inject null value into class
com.icemobile.albertheijn.ui.activity.recipes.RecipeSpinnerActivity.recipeReset
when field is not @Nullable
E/AndroidRuntime( 912): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
E/AndroidRuntime( 912): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
E/AndroidRuntime( 912): at
android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:
3278)
E/AndroidRuntime( 912): at android.app.ActivityThread.access
$1900(ActivityThread.java:112)
E/AndroidRuntime( 912): at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1696)
E/AndroidRuntime( 912): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 912): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 912): at
android.app.ActivityThread.main(ActivityThread.java:3948)
E/AndroidRuntime( 912): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 912): at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 912): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 912): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime( 912): at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 912): Caused by: java.lang.NullPointerException:
Can't inject null value into class
com.icemobile.albertheijn.ui.activity.recipes.RecipeSpinnerActivity.recipeReset
when field is not @Nullable
E/AndroidRuntime( 912): at
roboguice.inject.ViewMembersInjector.reallyInjectMembers(ViewListener.java:
106)
E/AndroidRuntime( 912): at
roboguice.inject.ContextScope.injectViews(ContextScope.java:105)
E/AndroidRuntime( 912): at
roboguice.activity.GuiceActivity.setContentView(GuiceActivity.java:75)
E/AndroidRuntime( 912): at
com.icemobile.albertheijn.ui.activity.recipes.RecipeSpinnerActivity.onCreate(RecipeSpinnerActivity.java:
134)
E/AndroidRuntime( 912): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
E/AndroidRuntime( 912): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
E/AndroidRuntime( 912): ... 12 more


apparently, RoboGuice tries to inject a View but it's null so it
throws an exception. This only happens when the activity is started
after a screen rotation. It doesn't happen at Activity first start. It
says the field should be @Nullable but if I make it @Nullable, I get a
null pointer exception because the View is null. What to do?

Xtine

unread,
Mar 17, 2010, 6:34:17 AM3/17/10
to roboguice
The view is an ImageView, other Views seem to be ok.

Xtine

unread,
Mar 17, 2010, 6:43:28 AM3/17/10
to roboguice
Err, never mind.

:-)

On Mar 17, 11:26 am, Xtine <christ...@christine.nl> wrote:

Reply all
Reply to author
Forward
0 new messages