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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:25:34+00:00 2026-05-25T03:25:34+00:00

I have developed an application to find the user’s location using GPS. In this

  • 0

I have developed an application to find the user’s location using GPS.

In this there is no error. It finds the location using Wifi correctly, but in GPS mode it doesn’t return any values. I added the needed permission in the manifest and GPS is on.

Can someone please tell me how to get the location using Gps?

I have included my code here:

package c.g.a.loation;

public class UseGps extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        LocationListener mlocListener = new MyLocationListener();
        mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                mlocListener);
    }

    /* Class My Location Listener */
    public class MyLocationListener implements LocationListener {

        @Override
        public void onLocationChanged(Location loc) {
            Geocoder gp = new Geocoder(getBaseContext());
            try {
                ArrayList<Address> address = (ArrayList<Address>) gp
                        .getFromLocation(loc.getLatitude(), loc.getLongitude(),
                                1);
                if (address != null && address.size() > 0) {
                    Toast.makeText(getBaseContext(), address.get(0).toString(),
                            Toast.LENGTH_LONG).show();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onProviderDisabled(String provider) {}

        @Override
        public void onStatusChanged(String arg0, int arg1, Bundle arg2) {}

        @Override
        public void onProviderEnabled(String arg0) {}
    }

    public void onProviderEnabled(String provider) {
        // Toast.makeText(
        // getApplicationContext(),"Gps Enabled",Toast.LENGTH_SHORT).show();
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {}
}
  • 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-05-25T03:25:34+00:00Added an answer on May 25, 2026 at 3:25 am

    I have two thoughts…

    1. Your code is not checking to make sure the GPS provider is enabled. I see commented out code send a Toast when ANY provider is enabled, but you might want to check that the GPS provider is enabled in onCreate().

    2. How long are you waiting to get the GPS location? The GPS_PROVIDER can sometimes take a while to get a GPS fix. I have seen TTFF (time to fist fix) values of over two minutes before. To make matters worse, I have seen drastic TTFF differences in different versions of Android as well as different devices.

    I would recommend that you also try getting a GPS fix from another app to see how long that takes. I generally launch either Google Maps, or GPS Status (free from the market) to get a feeling for how long they take to get a GPS fix. If you try Google Maps, be sure that it is getting the GPS fix and not only a location from the NETWORK_PROVIDER (the GPS icon at the top of your screen should stop flashing).

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

Sidebar

Related Questions

My boss have given me assignment to find how a web based application developed
We currently have developed an application using WCF. Our clients make connections to different
I imagine there are many of you out there who have developed an application
I have developed a window application in VS2005 using C#. I need to integrate
I have developed a Win32 application using C/C++, which runs on Vista and XP.
i have developed an application in which i fetch books using googleapibook search. I
I have developed a phonegap application. Now I need to find memory leak in
I have developed application for drawing some shapes (lines mostly) , now i need
I have developed the application in which i want to set the background color
I am new to iPhone world. I have developed an application, which I would

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.