Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBilly Ashmall
Courses Plus Student 6,610 PointsWhy does this crash on actual device if photo is taken in landscape when it returns to the activity?
This works perfect in the Genymotion emulator, it also works perfect if i take a picture in portrait orientation, however when i take the picture in landscape (the normal photo orientation) the app crashes when it gets back to the activity. There seems to be a null pointer exception...
java.lang.NullPointerException at com.websitedesigns.zero.three.ribbit.FriendsFragment$1.done(FriendsFragment.java:77) at com.parse.FindCallback.internalDone(FindCallback.java:45) at com.parse.FindCallback.internalDone(FindCallback.java:31) at com.parse.Parse$6$1.run(Parse.java:975) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5102) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)
It seems to be when the FriendsFragment tries to getListView().getContext() in the ArrayAdapter creation, i tried switching it to getActivity() and got the same results.
I also searched and tried moving the code from onResume to onActivityCreated and got the same results.
Any suggestions?
Billy Ashmall
Courses Plus Student 6,610 PointsBilly Ashmall
Courses Plus Student 6,610 PointsI resolved this by wrapping the code inside the done method with a try catch. I also kept the code in onActivityCreated where i had moved it to from onResume. So far it seems to be working this way.