package se.nekotronic.solsken; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class AboutActivity extends Activity { final private class MinLyssnare implements OnClickListener { @Override public void onClick(View v) { // TODO Auto-generated method stub TextView textvyn = (TextView) findViewById(R.id.weather_text); if (textvyn != null) { textvyn.setText(textvyn.getText() + "\n"); textvyn.setText(textvyn.getText() + "I AboutActivty:s MinLyssnare...\n"); } // returnResult("Retur från AboutAcvtivity!"); Intent i = new Intent(); Button b = (Button)v; String knapptext = "fel"; if (b == findViewById(R.id.about_back_button)) knapptext = "Back!!!"; else if (b ==findViewById(R.id.about_like_button)) knapptext = "Like!!!"; String ls = "[accuracy=n/a]"; if (latest_location != null) { ls = "[accuracy=" + latest_location.getAccuracy() + "]"; // textvyn.setText(textvyn.getText() + ls); } i.putExtra("resultat-värdet", "Retur från AboutAcvtivity " + ls + " (" + knapptext + ")!"); setResult(RESULT_OK, i); finish(); // Avslutar akiviteten } } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. makeUseOfNewLocation(location); } public void onStatusChanged(String provider, int status, Bundle extras) { } public void onProviderEnabled(String provider) { } public void onProviderDisabled(String provider) { } }; // Register the listener with the Location Manager to receive location updates locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); final Button bakåtknappen = (Button) findViewById(R.id.about_back_button); final android.view.View.OnClickListener lyssnaren = new MinLyssnare(); bakåtknappen.setOnClickListener(lyssnaren); final Button gillaknappen = (Button) findViewById(R.id.about_like_button); // final android.view.View.OnClickListener lyssnaren = new MinLyssnare(); gillaknappen.setOnClickListener(lyssnaren); } private Location latest_location = null; protected void makeUseOfNewLocation(Location location) { // TODO Auto-generated method stub latest_location = location; } }