My code records the current Longitude / Latitude and puts in an array and you can view all the history of these recordings in a GPSHistory Activity.

        btnGPSHistory = FindViewById<Button>(Resource.Id.btnGPSHistory);
        btnGPSHistory.Click += (sender, e) =>
        {
            var intent = new Intent(this, typeof(GPSHistory));
            intent.PutStringArrayListExtra("Answer", liGPSAnswer);
            StartActivity(intent);
        };

This converts the double to a string and puts in a string and sends it to an array.

    async private void GetGPS(object sender, EventArgs e)
    {
        if (here == null)
        {
            txtGPSAnswer.Text = "Try Again Later.";
            return;
        }

        dblLongitude = here.Longitude;
        dblLatitude = here.Latitude;

        strLongitude = dblLongitude.ToString("G");
        strLatitude = dblLatitude.ToString("G");

        strGPSAnswer = "Longitude: " + strLongitude + " Latitude: " + strLatitude;

        if (string.IsNullOrEmpty(strGPSAnswer))
        {
            txtGPSAnswer.Text = "";
        }
        else
        {
            txtGPSAnswer.Text = strGPSAnswer;
            liGPSAnswer.Add(strGPSAnswer);
            btnGPSHistory.Enabled = true;
        }                    
    }

This is from GPSHistory.cs

 namespace GPS2
 {
 [Activity(Label = "@string/GPSHistory")]
 public class GPSHistory : ListActivity
 {
     protected override void OnCreate(Bundle bundle)
     {
         base.OnCreate(bundle);

         // Create your application here
         var strLongitude = Intent.Extras.GetStringArrayList("Answer") ?? new string[0];

         this.ListAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, strLongitude);

    }
}
}

The code records the Longitude and Latitude fine and puts in the history page without any problems. My question is how do I attach a button to each of those items in an array that basically tells the program to make those coordinates as "current ones" so that the program can look those coords on the map. Thank you.

Related posts

Recent Viewed