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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:05:20+00:00 2026-06-02T22:05:20+00:00

I have unsuccessfully attempted to get GPS Location to work for my app under

  • 0

I have unsuccessfully attempted to get GPS Location to work for my app under Android. I would like to know what I might be doing wrong. I have so far tried the following methods:

  • Get GPS Location instantly via Android app
  • http://www.javacodegeeks.com/2010/09/android-location-based-services.html
  • http://about-android.blogspot.de/2010/04/find-current-location-in-android-gps.html

as well as many others, but all in vain.

Considering that all the solutions above worked for some or the other person, I will use this one to debug:

package my.namespace;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class HomeActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    LocationListener ll = new mylocationlistener();
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
    }

    private class mylocationlistener implements LocationListener {
    public void onLocationChanged(Location location) {
        if (location != null) {
        Log.d("LOCATION CHANGED", location.getLatitude() + "");
        Log.d("LOCATION CHANGED", location.getLongitude() + "");
        Toast.makeText(HomeActivity.this,
            location.getLatitude() + "" + location.getLongitude(),
            Toast.LENGTH_LONG).show();
        }
    }
    public void onProviderDisabled(String provider) {
    }
    public void onProviderEnabled(String provider) {
    }
    public void onStatusChanged(String provider, int status, Bundle extras) {
    }
    }
}

There were @override annotations for the 3 methods onProviderDisabled, onProviderEnabled and onStatusChanged. I had to remove them because Eclipse gave an error that these methods are not overriding a superclass.

I have added the permissions in the manifest file (ACCESS_FINE_LOCATION, ACCESS_MOCK_LOCATION, ACCESS_COARSE_LOCATION and INTERNET).

Does anyone have an idea what I might be doing wrong?

Edit:
running on Emulator (Android 2.2 API 8)

  • 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-02T22:05:23+00:00Added an answer on June 2, 2026 at 10:05 pm

    Make sure to enable GPS when you test your app. It would also help if you use NETWORK_PROVIDER and GPS_PROVIDER both. So that when GPS is not available you still get the location with NETWORK_PROVIDER.

    UPDATE:
    Also, if you are using emulator to test your app, make sure you emulate the GPS fix either from command line or using Eclipse. here is a link to stackoverflow question about how to do this How to emulate GPS location in the Android Emulator?

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

Sidebar

Related Questions

I have been trying, unsuccessfully, to get unit tests running on my project (vs2010
I have been trying to get thumbnails to work with an AsyncTask for image
I have a section of a mapped image that I would like to initiate
I have an app that attempts to retrieve an iAd and if is unsuccessful
I have tried unsuccessfully to copy the pwd to pbcopy as follows pwd |
I have been trying to setup git for our web development team unsuccessfully. Some
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a piece of C code that looks like this: const char (*foo)[2]
I have developed a desktop application (.NET 2.0) and it needs to get some
I have an app where an user action attempts to connect to an online

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.