Hi

I am really a beginner and this is the code I am running to get
latitude and longitude...

package com.GPSAndroid;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

public class GPSAndroid extends Activity{

        private LocationListener myLocationListener;
    private LocationManager myLocationManager;
    public String latitude, longitude;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        myLocationManager = (LocationManager)getSystemService
(Context.LOCATION_SERVICE);
                myLocationListener = new MyLocationListener();

        myLocationManager.requestLocationUpdates
(LocationManager.GPS_PROVIDER, 1, 1, myLocationListener);

//HERE UNCOMMENT
// latitude=String.valueOf(myLocationManager.getLastKnownLocation
(LocationManager.GPS_PROVIDER).getLatitude());
      //  Log.v("GPS","GPS latitude:"+latitude);


    }

   public class MyLocationListener implements LocationListener{

        public void onLocationChanged(Location argLocation) {
                if(argLocation != null){
                        latitude = String.valueOf(argLocation.getLatitude());
                        longitude = String.valueOf(argLocation.getLongitude());
                }
        }
        public void onProviderDisabled(String provider) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onStatusChanged(String provider, int status, Bundle
arg2) {
        }

    };

}

But when I uncomment latitude line I got error? What do I do wrong?

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to