1

The question doesn't really make sense, but this should help explain it better.

I'm currently using the IOIO, and it works like this:

public class MainActivity extends CustomIOIOActivity {}

From there I can call classes I've made in CustomIOIOActivity, which extends Activity.

The problem I'm running into now is that I have to inherit classes different from just Activity. For example, FragmentActivity.

Is there a way for me to create a custom IOIO activity which I can use for when I extend Activity and FragmentActivity? I don't want to have to make two essentially identical classes, which is what I am doing right now--seems silly. I'm not very familiar with Java, perhaps this is easy to do.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
felix2018
  • 79
  • 6

1 Answers1

0

In Java you can't inherit class from more than one superclass. In order to achive your purpose, I would advise you to move all common logic to another class(IOIOHolder, for example), which would take an Activity parameter in constructor. Later you can create two different classes extending Activity and FragmentActivity, each containing an exemplar of IOIOHolder and using it for it's own tasks. By using this approach you can write IOIO code once and use it in any activity you want.

Maxim Efimov
  • 2,747
  • 1
  • 19
  • 25