Stackingcoder Stackingcoder - 3 months ago 39
Android Question

How do i extend multiple classes in Android Studio?

I am following a tutorial on YouTube yo request permissions
at runtime. I created a Java Class called: AbsRuntimePermission and i have to extend it on my MainActivity.
But i also have to extend AppCompatActivity, is there a way to extend both?
Because if i try that it will give me a error:

Class cannot extend multiple classes

And i am trying like this:

public class MainActivity extends AppCompatActivity, AbsRuntimePermission {

I hope someone can help me out, i am following this tutorial:


You can't extend more than one classes in JAVA.

You can extend AbsRuntimePermission with AppCompatActivity

and extend MainActivity with AbsRuntimePermission. Because AbsRuntimePermission is already extended with AppCompatActivity which means MainActivity is also extended with AppCompatActivity.

public class AbsRuntimePermission extends AppCompatActivity{

public class MainActivity extends AbsRuntimePermission {