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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:53:01+00:00 2026-05-14T16:53:01+00:00

is it possible, that android cleares the last known location after a restart? Yesterday

  • 0

is it possible, that android cleares the last known location after a restart?
Yesterday my code worked very fine, but today after rebooting my phone (AND emulator) it seems that the .getLastKnownLocation (see below) returns null, which leads to a nullPointerException…
Can you confirm that?
How can I avoid this problem? I’m desperately searching for an answer

lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

…

Location locUser = lm
    .getLastKnownLocation(LocationManager.GPS_PROVIDER);
posUser = new GeoPoint((int) (locUser.getLatitude() * 1E6),
(int) (locUser.getLongitude() * 1E6));

Would be great if someone coult give me a hint or point out my mistake.

Nice greetings, Poeschlorn

  • 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-14T16:53:02+00:00Added an answer on May 14, 2026 at 4:53 pm

    The call to getLastKnownLocation() doesn’t block – which means it will return null if no position is currently available, which is very likely after a device restart. I would be surprised if Android caches the current location when a user switches a device off since it is likely that the device will move before it is switched back on again.

    You’ll need to pass a LocationListener to the requestLocationUpdates() method instead, which will give you asynchronous updates of your location.

    Have a look at this question for an example of using a LocationListener.

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

Sidebar

Related Questions

Is it possible to create an IntentFilter in android that matches ALL intents that
Is it possible to change Android Tabs that if you press one, it comes
Is it possible to programmatically create VPN profile on Android (assuming that I have
Possible Duplicate: How to list my app downloads I created an android app that
Is it possible to deploy a mobile profile on an Android device that enforces
Possible Duplicate: Android Button: set onClick background image change with XML? I need that
Is it possible to override the standard layouts that are provided with Android? Is
I want to find out if it is possible to create Android API's that
Is it possible make an activity, that will lock the android device? That device
I need HTTP/RTSP Video Streaming with Android. Any Ideas ? Is that possible 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.