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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:41:21+00:00 2026-05-20T12:41:21+00:00

I am working on an Android app and I need to make sure that

  • 0

I am working on an Android app and I need to make sure that the device has reached a certain point described with lat and lon. The only thing that I can think of is to have something like that :

    Location initLoc = theManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    double lat = initLoc.getLatitude();
    double lon = initLoc.getLongitude();
    MyPoint firstPoint = getPoints().get(0);

    double dist = CalcHelper.getDistance1(lat, lat, firstPoint.getLat(), firstPoint.getLon());

    while(dist > 30){

        initLoc = theManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        lat = initLoc.getLatitude();
        lon = initLoc.getLongitude();
        dist = CalcHelper.getDistance1(lat, lon, firstPoint.getLat(), firstPoint.getLon());

    }

But that causes the program to crash. I would be very appreciative if you could lead me to the right direction here.

Let me take the opportunity to ask a further question. As I said I am new to Android and GPS and having in mind there is little documentation and information on how to properly develop applications that work with GPS I am working in blind basically. So my question is:

This is how the onLocationChanged method looks like:

            public void onLocationChanged(Location location) {

            double lat = location.getLatitude();
            double lon = location.getLongitude();
            MyPoint firstPoint = MainScreen.dataset.getPoints().get(0);

            double dist = CalcHelper.getDistance1(lat, firstPoint.getLat(),lon, firstPoint.getLon());

            if(dist < 10){

                Context context = getApplicationContext();
                CharSequence text = "Start reached. Starting moving on track";
                int duration = 6000;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();   

            }else{

                Context context = getApplicationContext();
                CharSequence text = "Distance until start: "+dist;
                int duration = 6000;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();

            }

    }

What I am trying to do is to make the program determine when I have reached the start of a track I have supplied as a set of points. So, when I start the program I receive a reasonable estimate on the distance. The problem is, when I start moving, the distance does not seem to be updated, it gets updated but after moving 50meters, it says i have only moved 5 say. On the other hand, when I start the application and I am less than 10m away from the starting point, it detects it properly. So basically, while I am moving with the device, the onLocationChanged method does not seem to give me the correct location that I am now on. Can you tell me what I might be doing wrong ?

  • 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-20T12:41:21+00:00Added an answer on May 20, 2026 at 12:41 pm

    Look at this it might be exactly what you’re needing

    Proximity Alert

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

Sidebar

Related Questions

I am working on an Android app that has multiple screens the user will
I am currently working on my first android app. In a listview, I need
I'm working on my first Android app, and am almost to the point where
I'm working on an app for Android with a few other people, and the
I created a Twitter app I need user of my Android application to authorize
Working on an Android app where I would like to display the number of
I'm working on an android app where I have only 2 activities... The first
Here i make 5 Tab buttons that are working proper but now i want
I've been working on the Android SDK platform, and it is a little unclear
Working with a SqlCommand in C# I've created a query that contains a IN

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.