I am using this class A which extends another abstract class (and this abstract class extends FragmentActivity) and in one of my function with in A class I want to get getActivity() for my current activity A. But whenever I use getActivity , It gives me error that getActivity() method is not defined type for my class. Please help me !! How can I achieve this??
Code for my class A
public class A extends B
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.voicing);
//doing another initializations and stuff//
}
}
code for class B
public abstract class B extends FragmentActivity
{
FragmentAdapter mAdapter;
ViewPager mPager;
PageIndicator mIndicator;
}
A
FragmentActivityis an instance ofActivity(in Java style:FragmentActivity extends Activity).So there is no point calling
getActivitybecause aFragmentActivityis already anAcivity, so just calling/usingthiswill work. Also there is no method calledgetActivityin theFragmentActivityclass. In other words your B class is extending anActivityinstance.So inside your A (or B) class you could use this code snippet to get the activity instance:
But if your B class extends
Fragmentthen thegetActivitycall would have worked.