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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:43:15+00:00 2026-05-12T18:43:15+00:00

I am trying to design my first Android application with the use of GPS.

  • 0

I am trying to design my first Android application with the use of GPS. As of right now, I have a drawable button that when clicked, alerts a Toast message of the longitude and latitude. I have tried to use the telnet localhost 5554 and then geo fix #number #number to feed in values but no results display just 0 0. I have also tried DDMS way of sending GPS coordinates and I get the same thing.

My question is what exactly is the correct way of using the geo fix and the DDMS way of sending coordinates. I have used Location, LocationManger and LocationListener but I am not sure which is the right choice.

Code is given, just in case if the error exists with the code

@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button button = (Button) findViewById(R.id.track);
    button.setOnClickListener(this);
    LocationManager location =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
    Location loc = location.getLastKnownLocation(location.GPS_PROVIDER);
    updateWithNewLocation(loc);

  }

 private final LocationListener locationListener = new LocationListener() {
   public void onLocationChanged(Location location) {
     updateWithNewLocation(location);
   }

  private void updateWithNewLocation(Location l) {
  longitude = l.getLongitude();
  latitude = l.getLatitude();
  provider = l.getProvider();     
  }

    public void onClick(View v) { 
     Toast.makeText(this, "Your location is " + 
      longitude + " and " + latitude + " provided by: " + 
      provider, Toast.LENGTH_SHORT).show();          
   }     
}
  • 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-12T18:43:15+00:00Added an answer on May 12, 2026 at 6:43 pm

    Two things

    1) Make latitude and longitude volatile

    2) Try registering as a listener to the GPS location manager

    location.requestLocationUpdates(LocationManager.GPS, 100, 1, locationListener);

    That should get you callbacks sent to your locationListener object.

    You can check out some sample Android GPS code here:
    http://www.devx.com/wireless/Article/43005

    (WARNING! DevX has added a registration landing since I’ve added this link!)

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

Sidebar

Related Questions

I'm trying to design an application that will use a DB to store some
I'm trying to design an Android layout that would look like the following: Entity1
I'm trying to design an application that saves the selection I made on a
I have an App that I am trying to design the data model for.
I am trying to design Log File Parser for my application. I have thousands
I'm trying to design an interface for a web-based application that allows the user
I am trying to implement my first WPF application using an MVVM design pattern.
I'm trying to learn EF using code first, i dont know how to design
Intro I am in the process of trying to convert my first HTML/CSS design
I'm trying to design my app's interface in IB using a storyboard and have

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.