6

I want to use Fragments in my application, but I cannot extend FragmentActivity because my application already extends an activity that is part of a library. Since this means that I cannot call getSupportFragmentManager(), I am looking for a workaround that would allow me to use Fragments without having to extend FragmentActivity. Is it possible?

JohnEye
  • 6,436
  • 4
  • 41
  • 67
  • 1
    This is unfortunately not possible. Is the library of yours or open source? You might change the Activity you extend and make it extend FragmentActivity instead of Activity – Benoît Bouré Oct 03 '12 at 13:47
  • Are you sure? I read somewhere that it could be possible using some Interface magic. The library is indeed open source, but I wanted to avoid changing it so as to keep being able to update it from the repository. – JohnEye Oct 03 '12 at 13:56
  • 1
    Not sure how it could be done properly without extending FragmentActivity. Have you considered asking the library developer for Fragment Support? – Benoît Bouré Oct 03 '12 at 14:06
  • Wouldn't that make the support package mandatory for everyone? – JohnEye Oct 03 '12 at 14:14
  • 1
    Good point. I don't know what library you are using. It could have a CustomActivity and a customFragmetnActivity... Don't know... – Benoît Bouré Oct 03 '12 at 14:19

1 Answers1

2

Your library is going to need to extend the FragmentActivity.

I would be concerned about a library that requires you to use their base activities anyway.

As mentioned (where possible) grab the library source code and add it as a library project to eclipse and make its activities extend the FragmentActivity class.

Chris.Jenkins
  • 13,051
  • 4
  • 60
  • 61