Ovi
Ovi

Reputation: 60

How to implement parent methods to activity and FragmentActivity?

I am working on an android application, and I have number of activities that extend from a custom activity.

Now I created a new FragmentActivity and I need the same functions that I have implemented in my custom activity.

How can I do that?

Edit

This is an simple example

public class BaseActivity extends Activity
{
    protected void someFunction()
    {
        Log.i("TEST","This is a test");
    }
}

public class MainActivity extends BaseActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        someFunction();
    }
}

this is my FragmentActivity:

public class MyFragmentActivity extends FragmentActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // here I want to use someFunction()..
    }
}

Upvotes: 2

Views: 446

Answers (1)

Taras
Taras

Reputation: 2576

In Java you can't extend more than one class. So I guess you should extend BaseActivity from FragmentActivity instead of Activity

Upvotes: 2

Related Questions