Forum Xamarin.Android

How to get data from a web service REST

VictorManriqueVictorManrique USMember ✭✭
edited November 2016 in Xamarin.Android

I have a problem, when using this class to get the list of information of a service I debug the list empty and when using the interrupt point mode I realize that I return the list first and then does the process inside the RunOnUiThread () , Someone to tell me I'm doing wrong ..

public class EntidadAcceso : Activity { private List<User> mContacts = new List<User>(); private WebClient mClient = new WebClient(); private Uri mUrl; public List<User> GetUser() { mUrl = new Uri(""); mClient.DownloadDataAsync(mUrl); mClient.DownloadDataCompleted += (object sender, DownloadDataCompletedEventArgs e) => { RunOnUiThread(() => { string json = Encoding.UTF8.GetString(e.Result); mContacts = JsonConvert.DeserializeObject<List<User>>(json); }); }; return mContacts; } }

Best Answers


Sign In or Register to comment.