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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:28:46+00:00 2026-06-03T00:28:46+00:00

I am trying to get an Current Altitude from location.getAltitude() method. but it always

  • 0

I am trying to get an Current Altitude from location.getAltitude() method. but it always returns zero. what should i do to get current altitude value. but getting longitude and lattitude correctly. please advice me. i have searched in google and worked out some samples but all are returned zero only.

Code which i have used :

in on create i have called =getMyCurrentLocation(); this method.

void getMyCurrentLocation() {
        LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        LocationListener locListener = new MyLocationListener();
try{gps_enabled=locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);}catch(Exception ex){}
           try{network_enabled=locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);}catch(Exception ex){}  
if(gps_enabled){

                locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);

            }

            if(network_enabled){
                locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);

            }


        if(gps_enabled){
                location=locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);



            }

            if(network_enabled && location==null)   {
                location=locManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);  

            }

        if (location != null) {

            MyLat = location.getLatitude();
            MyLong = location.getLongitude();
    Toast.makeText(this,"My Lat : " + MyLat + "\n" + "My Long : " + MyLong, Toast.LENGTH_SHORT).show();

        } else {

        }


        System.out.println(" LATTITUDE " + MyLat);
        System.out.println("Longitude " + MyLong);

    }


public class MyLocationListener implements LocationListener

        {

        @Override

        public void onLocationChanged(Location loc)

        {

        MyLat =loc.getLatitude();
        MyLong=   loc.getLongitude();
       gooalt=getElevationFromGoogleMaps(MyLat,MyLong) ;
      double alt=loc.getAltitude(); **==>>> This one returns ZERO**

        String Text = "Longitud = " + (loc.getLongitude()) +"Latitud = " + loc.getLatitude()+"Altitude "+gooalt+"feet";

        Toast.makeText( getApplicationContext(),Text,Toast.LENGTH_SHORT).show();


        }

        @Override

        public void onProviderDisabled(String provider)

        {

        Toast.makeText( getApplicationContext(),"Gps  Disabled",Toast.LENGTH_SHORT ).show();

        }

        @Override

        public void onProviderEnabled(String provider)

        {

        Toast.makeText( getApplicationContext(),"Gps   Enabled",Toast.LENGTH_SHORT).show();

        }

        @Override

        public void onStatusChanged(String provider, int status, Bundle extras)

        {

        }

        }
  • 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-03T00:28:51+00:00Added an answer on June 3, 2026 at 12:28 am

    What method did u used to get the location?
    Maybe u could try http://developer.android.com/reference/android/location/LocationManager.html#getLastKnownLocation(java.lang.String) instead, that worked for me.

    If not, maybe try another approach, there are several ones:
    http://developer.android.com/guide/topics/location/index.html

    BTW: could u give us some code? On what device are you testing?

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

Sidebar

Related Questions

I am trying to get the current trends from the twitter api (but that's
I'm trying to get current Executing Job with the method scheduler.getCurrentlyExecutingJobs(); but I really
I'm trying to get the current user login status via javascript sdk but I
I'm trying to get the query string from a string (not the current URL).
I'm trying to get the number of days from 1st of current month of
I am trying to get the current value of a jQuery-UI slider in a
I'm trying to get my current location and show it on a map. Class
I'm trying to get my current program to take information from a dynamically created
I am trying to get current location of user using CLLocationCoordinate2D. I want the
I am trying to Set Location but getting NullPointerException , i have Provided android.permission.ACCESS_COARSE_LOCATION

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.