First time ko gumamit ng xamarin, at may error siya kapag nagko-connect ako sa RESTful API kapag unang beses kong pinipindot yung button, sa sumusunod na pindot ay gumagana na siya. Paano ba i-capture yung error? Gumagamit ako ng android device na naka-connect using USB.
C#:
private async void BtnConnect_Click(object sender, EventArgs e)
{
try
{
txtUsername = FindViewById<TextView>(Resource.Id.txtUsername);
txtPassword = FindViewById<TextView>(Resource.Id.txtPassword);
string username = txtUsername.Text;
string password = txtPassword.Text;
var user = new UserModel
{
username = username,
password = password
};
ApiResponse response = await ApiUtils.GetApiService().Login(user);
Toast.MakeText(this, response.message, ToastLength.Long).Show();
}
catch (Exception ex)
{
Toast.MakeText(this, ex.StackTrace, ToastLength.Long).Show();
}
}