Hello all,
I was hoping that SDK 1.1 would solve some problems I've had using
Emulator Location Control or telnet command line to update my location
for the simple example program below. I haven't had any luck with
this. I'm on Windows XP, SDK 1.1, Eclipse 3.4, ADT plugin. I've check
my Language Options as described here
http://groups.google.com/group/android-beginners/browse_thread/thread/2b0b99c25ea9bbbf/9f3a4bb451147ee1?lnk=gst&q=Eclipse+Emulator+Control&pli=1,
but with no luck.

Any ideas?


package com.android.WhereAmI;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;

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

        LocationManager locationManager;
        String context = Context.LOCATION_SERVICE;
        locationManager = (LocationManager)getSystemService(context);

        String provider = LocationManager.GPS_PROVIDER;
        Location location = locationManager.getLastKnownLocation(provider);
        updateWithNewLocation(location);

    }

    private void updateWithNewLocation(Location location)
    {
        String latLongString;
        TextView myLocationText;
        myLocationText = (TextView)findViewById(R.id.myLocationText);
        if (location!=null)
        {
                double lat = location.getLatitude();
                double lng = location.getLongitude();
                latLongString = "Lat: "+ lat +"\nLng: "+ lng;
                
        }
        else
        {
                latLongString = "No Location Found";
                
        }
        myLocationText.setText("Your Current Location is:\n"+latLongString);
    }
}
-----------------------------------------------------------------------------------------------------------------------------------------

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

Reply via email to