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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:41:01+00:00 2026-06-13T15:41:01+00:00

To be clear: This is an activity in my Android application that is meant

  • 0

To be clear: This is an activity in my Android application that is meant to pull the coordinates for the users location using the GPS_PROVIDER. The Activity contains a button which, when pressed, should initiate a method that obtains the coordinate data. The problem is that the application crashes when there is no previously known location information (ie if the phone was recently reset). If I open up the Maps application (for example) and pinpoint my location, then re-open my own application and run this method, it works as intended. My question is why is this crashing and/or how can I prevent this crash from occurring? Help is appreciated, thanks.

This method is run when the button is pressed – and an intent response is generated back to the calling activity when the coordinates are properly found:

protected void getCurrentLocation() {
    Location location = null;
    try {
        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    } catch (IllegalArgumentException iae) { }

    if (location != null) {
        longV = location.getLongitude();
        latV  = location.getLatitude();
        response(longV, latV);
    } else {
        getCurrentLocation();
    }
  • 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-13T15:41:02+00:00Added an answer on June 13, 2026 at 3:41 pm

    I’m guessing that you are receiving a StackOverflowException, because if location is null you call the exact same function creating an indefinite loop…

    If there is no last know location, you need to request a new location. (getLastKnownLocation() will not change on its own no matter how many times you call it.)

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

Sidebar

Related Questions

i have coded an android application that will update GPS coordinates to the exif
Hoping that someone can help clear up this very annoying situation I find myself
HI Am working for the application using tabs through entire app.In that one particular
i am working in an application, i seen that guide: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ and i make
I currently have a notification in my Android application that has a PendingIntent so
It is well known that Android places our application components (Activities, Services) under threat
I'm building and Android application using ActionBarSherlock . I have multipe types of activities:
I am getting this exception when trying to start an activity (TestLocationActivity) that is
I am writing an application for Android that needs to respond as fast as
I've to develop an android application and one of its activity is: Detecting New

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.