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 8875057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:52:53+00:00 2026-06-14T18:52:53+00:00

When I am using the getApplicationContext() that time eclipse give me error create method

  • 0

When I am using the getApplicationContext() that time eclipse give me error create method 'getApplicationContext()'. Please let me know How to remove this error. I am try also using ClassName.this that time error like change method startListening(Context) to startListening(Main)

Also when I use like : measurement_index = AppSettings.getMeasureUnit(this);
then Error like :change method getMeasureUnit(Context) to getMeasureUnit(Main)

So please let me know how can solve error like:

  1. create method ‘getApplicationContext()’

  2. change method getMeasureUnit(Context) to getMeasureUnit(Main)

Check my code.

Main.class

public class Main extends Fragment implements GPSCallback{

....... 

public static Fragment newInstance(int position) {
    Main f = new Main();
    Bundle args = new Bundle();

     ...

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.main, null);

    /*Intent in = new Intent(Main.this,MainDisplay.class);
              // ------------> Here give error like : Remove arguments match to Intent();
    startActivity(in);*/

    tv_display_Speed = (TextView) root.findViewById(R.id.speed_display);

     gpsManager = new GPSManager();

        gpsManager.startListening(getApplicationContext());
                   //------------>  Eclipse give me error create method 'getApplicationContext()'

        gpsManager.setGPSCallback(this);

        //(TextView)root.findViewById(R.id.speed_display);

        measurement_index = AppSettings.getMeasureUnit(this);
                   //------------> Here Give me error like : change method getMeasureUnit(Context) to  getMeasureUnit(Main) 


    btnstart = (Button) root.findViewById(R.id.button_start);
    btnstart.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub


        }
    });

    return root;
}

startListening method:

public void startListening(final Context context)
{
     ....
}

getMeasureUnit method:

public static int public static int getMeasureUnit(Context context){
    return getInt(context,AppSettings.UNIT_STRING);
} 

EDIT :

I have Added the onStart() method into above class that extends fragment.
That time at runOnUiThread(updateTask); Eclipse give me error like : create method runOnUiThread(Runnable) .Please let me know how can I achieve this.

@Override
public void onStart() {
    super.onStart();
    timer = new Timer("DigitalClock");
    Calendar calendar = Calendar.getInstance();

    // Get the Current Time
    final Runnable updateTask = new Runnable() {
        public void run() {
            txt_display_clock.setText(getCurrentTimeString()); // shows the current
                                                        // time of the day

        }
    };

    // update the UI
    int msec = 999 - calendar.get(Calendar.MILLISECOND);
    timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(updateTask); // <---------------- HERE
        }
    }, msec, 1000);
}
  • 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-14T18:52:54+00:00Added an answer on June 14, 2026 at 6:52 pm

    In a Fragment, you can use getActivity().getApplicationContext() instead.

    As for the AppSettings.getMeasureUnit error, if the getMeasureUnit method is expecting a context you can usually use getActivity().getApplicationContext().

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

Sidebar

Related Questions

Using CI for the first time and i'm smashing my head with this seemingly
I know that there are a few Questions here on SO relating to this,
I am using AndEngine for my game. In that I want to give option
This is my first time using HtmlUnit and I am using it within the
In my ongoing learning process (dialog boxes this time), I discovered that this works:
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using import datetime in python, is it possible to take a formatted time/date string
I have learned that when using android:entries with a ListView , it uses android.R.layout.simple_list_item_1
i am using a background service that it is retrieving data and inserting data
i'm using actionbar sherlock/fragments with my app my problem is that i need to

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.