Search code examples
javaandroidoopmultiple-inheritancecode-reuse

Function reuse in android


I have a native android application with about 20 Classes for 10 Activities.

I want to reuse a function definition in every Activity. I have a bottom bar and clicking on it from any activity should trigger this function. Since Java cant have multiple inheritance, how do i copy this function to where ever i want?


Solution

  • Make BasicActivity class and extend it from Activity and write that method inside it.

    and now extend every Activity in your application from BasicActivity