Android Sliding Menu Getactivity Returns Null
I've been searching for this for a while now and haven't found any solution so far, so I have a sliding menu, and withing it I call getActivity(), so far so good, but when I get o
Solution 1:
You have to be careful about exactly when you call getActivity(). It will return null in any call triggered by the parent activity's lifecycle all the way through onResume(). You have to make sure it is already attached to the parent activity before you can safely call it. Take a look at
Perhaps it will help you resolve your problem.
Depending on what you're trying to do, I would look into saving a pointer to the activity in the fragment so it can be referenced at times when getActivity might be null. That said, this could be kinda dangerous so be careful if that is the route you choose to take
Post a Comment for "Android Sliding Menu Getactivity Returns Null"