Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8614181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:03:46+00:00 2026-06-12T05:03:46+00:00

I am using this class A which extends another abstract class (and this abstract

  • 0

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;


 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:03:48+00:00Added an answer on June 12, 2026 at 5:03 am

    A FragmentActivity is an instance of Activity (in Java style: FragmentActivity extends Activity).

    So there is no point calling getActivity because a FragmentActivity is already an Acivity, so just calling/using this will work. Also there is no method called getActivity in the FragmentActivity class. In other words your B class is extending an Activity instance.

    So inside your A (or B) class you could use this code snippet to get the activity instance:

    Activity test = (Activity) this;
    

    But if your B class extends Fragment then the getActivity call would have worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android activity in which I'm using tabs. public class UnitActivity extends
I have Class which Extends View I'm able To Move one Image Over another
i have one single class for margin and i am using this class to
I wrote a simple library in which the user extends one of my abstract
Actually I have two java classes of which one is an activity class. Now
I am using this class to load multiple images synchronously. Somehow the loader doesn't
I tried to send an email using this class below, but no success, no
I'm using this php class ( http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php ) for creating the different sized images
I am using this WebCrawler class http://phpcrawl.cuab.de . There is a method named setTmpFile()
I've embedded a SWF into a class using this syntax above my class definition:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.