--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2009/08/08 20:09:47 238 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2009/08/09 09:09:16 239 @@ -7,6 +7,7 @@ import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.view.View; @@ -32,6 +33,8 @@ DepartureFetcher fetcher; + double latitude,longitude; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -41,12 +44,17 @@ setListAdapter(adapter); Intent launchedBy = getIntent(); + + latitude = launchedBy.getDoubleExtra("latitude", 0.0); + longitude = launchedBy.getDoubleExtra("longitude", 0.0); + String name = launchedBy.getStringExtra("name"); ((TextView) findViewById(R.id.stationName)).setText( name ); String addr = launchedBy.getStringExtra("address"); ((TextView) findViewById(R.id.stationAddr)).setText( addr ); + findViewById(R.id.header).setOnClickListener( mapLauncher ); NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(1); @@ -129,6 +137,14 @@ } } + View.OnClickListener mapLauncher = new View.OnClickListener() { + @Override + public void onClick(View v) { + Uri uri = Uri.parse("geo:" + latitude + "," + longitude); + startActivity( new Intent(Intent.ACTION_VIEW, uri)); + } + }; + class DepartureFetcher extends AsyncTask {