0

I am trying to use Square's Mortar and Flow

The problem is: ActionBarDrawerToggle from support-v7 requires to have a reference to the Activity

However view.getContext() returns PathContext so i get

ClassCastException: flow.path.PathContext cannot be cast to android.app.Activity

So how do I get reference to activity?

2

1 Answer 1

1

Try to use getBaseContext() method of ContextWrapper class that is superclass of PathContext.

5
  • Thanks for the answer. Спасибо! I've managed to find my activity like this: ((PathContext) ctx).getBaseContext().getBaseContext().getBaseContext().getBaseContext() But It does not look like good solution ;( Apr 27, 2015 at 16:48
  • @KorniltsevAnatoly My answer has the official Google docs. Read the docs. If you are using an Activity all you need is this. Apr 27, 2015 at 16:50
  • @JaredBurrows I do not use activity or fragment. I've updated my question to mention it. Apr 27, 2015 at 16:57
  • @KorniltsevAnatoly You down vote me then update your question. That's really counter intuitive. Apr 27, 2015 at 17:00
  • @JaredBurrows Yes, my fault. Apr 27, 2015 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.