I have a base class for my all of activities (ActivityBase
) that itself derives from android.app.Activity
. In onCreate I want to execute some conditio
Use instanceof operator.
Supposing you have a base class and two subclasses named Base
, SubOne
and SubTwo
, if you want to check if a variable ref
is an instance of SubOne
or SubTwo
you'd say:
if(ref instanceof SubOne){
}
else if(ref instanceof SubTwo){
}
Note that: (ref instanceof Base)
will always return true
though.