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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:08:04+00:00 2026-06-16T03:08:04+00:00

When I run my app on Android 4.2 OS phone, I can’t seem to

  • 0

When I run my app on Android 4.2 OS phone, I can’t seem to be able to get any values returned from getLAstKnownLocation ( always null )
The weird thing is that the Mapview works fine and it shows me my current location !!

Any ideas how to solve this issue ?

here is my code

in onCreate:

mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
provider = mlocManager.getBestProvider(criteria, false);
mlocManager.requestLocationUpdates(provider, 0, 0, geoHandler);

then the listener:

public class GeoUpdateHandler implements LocationListener {
    public void onLocationChanged(Location location) {
        // called when the listener is notified with a location update from the GPS
        int lat = (int) (location.getLatitude() * 1E6);
        int lng = (int) (location.getLongitude() * 1E6);
        new GeoPoint(lat, lng);

        Log.d(this.getClass().getSimpleName(), "onLocationChanged " + lat);
        //          mlocManager.removeUpdates(this);
    }

    public void onProviderDisabled(String provider) {
        // called when the GPS provider is turned off (user turning off the GPS on the phone)
        Log.d(TAG, "DISABLED");
    }

    public void onProviderEnabled(String provider) {
        // called when the GPS provider is turned on (user turning on the GPS on the phone)
        Log.d(TAG, "ENABLED");
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
        // called when the status of the GPS provider changes
        Log.d(TAG, "CHANGED");
    }
}
  • 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-16T03:08:06+00:00Added an answer on June 16, 2026 at 3:08 am

    getLastKnownLocation will return a null when the provider is disabled. Or when there is no LastKnownLocation.

    On the line: provider = mlocManager.getBestProvider(criteria, false);

    your provider is asking for the BestProvider including disabled providers. Try using true at the end of the statement and see if that works.

    http://developer.android.com/reference/android/location/LocationManager.html#getLastKnownLocation(java.lang.String)

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

Sidebar

Related Questions

I'm trying to be able to run my mobile app on my android phone,
I can run and debug my Android app on my phone just fine, most
while i'm developing my android app on my HTC sensation, i can't run the
I'm making an Android app where the user can download files from a FTP-server.
My new Android app is crashing when I run it on my phone, but
This android app Plan B claims that you can install and run it remotely,
I'm trying to run an android app from eclipse on my device (moto droid2).
I've written app for Android 2.2 (target version) and I tried to run it
I have been using Eclipse to compile and run my development Android app. Now
I just tried to run my company's app in the new x86 android emulator,

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.