import java.util.List; import java.net.URLConnection; import java.net.URL; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.location.LocationManager; import android.location.LocationProvider; import android.location.Location; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentReceiver; public class helloworld extends Activity { /** Called when the activity is first created. */ //@Override public TextView tv = null; public LocationManager locationManager = null; public void onCreate(Bundle icicle) { super.onCreate(icicle); this.tv = new TextView(this); this.locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); String LOCATION_CHANGED = "location changed"; IntentFilter filter = new IntentFilter(LOCATION_CHANGED); myIntentReceiver receiver = new myIntentReceiver(); registerReceiver(receiver, filter); List providers = locationManager.getProviders(); LocationProvider gpsprovider = providers.get(0); Intent intent = new Intent(LOCATION_CHANGED); locationManager.requestUpdates(gpsprovider, 0, 0, intent); setContentView(tv); } public void updateLocation() { URL urlConn = new URL("http://www.google.com:80/"); URLConnection httpConn = urlConn.openConnection(); Location location = this.locationManager.getCurrentLocation("gps"); this.tv.setText("Hello, World. " + location.convert(location.getLatitude(),location.FORMAT_DEGREES) + location.convert(location.getLongitude(),location.FORMAT_DEGREES)); } }