All pastes #802678 Raw Edit

Untitled

public java v1 · immutable
#802678 ·published 2007-11-30 15:19 UTC
rendered paste body
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<LocationProvider> 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/");    	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));    	    }}