Is it good to have BaseActivity
class and that will act as super class for all other activity. I need this to have some common implementations for the activities.
BaseActivity:
public class BaseActivity extends Activity
{
//All Common implementations goes here
}
Activities
public class HomeActivity extends BaseActivity
{
}
I have used this type of BaseActivity for all common method cover.
In my every activity.
Happy coding :)
In this case, I suggest having a base abstract activity, and two concrete inherited subclasses. You define all the common behaviour in the base activity, and have abstract methods for the differences, which you then override in your actual implementations.
For example, for two activities with different layout resources:
You can have a lot more abstract methods, for every bit you want specific to your subclasses.
Doing that is, in my opinion, a lot better than having a concrete subclass to a concrete superclass: that can lead to many problems and is usually difficult to debug.
Happy coding. Let me know need more help!!
It all depends with your requirement, but for the sake of scalability it has always been handy to have a base class to put all your shared functions. I will hugely suggest to use abstract class just incase you need to define different implementation of shared behaviors, like getting the class name or screen name.