Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using Android.OS;
- using System.Net;
- using System.Text;
- using Android.Widget;
- namespace HttpTest
- {
- [Activity(Label = "HttpGetAndroid", MainLauncher = true, Icon = "@drawable/icon")]
- public class MainActivity : Activity
- {
- int count = 1;
- protected override void OnCreate(Bundle bundle)
- {
- base.OnCreate(bundle);
- SetContentView(Resource.Layout.Main);
- TextView MessageLabel = FindViewById<TextView>(Resource.Id.SecondName);
- EditText NameTxt = FindViewById<EditText>(Resource.Id.Name);
- EditText SecondName = FindViewById<EditText>(Resource.Id.SecondName);
- Button SendBtn = FindViewById<Button>(Resource.Id.Send);
- string user = "VistaVerde";
- string password = "VistaVerdaPasswordExample";
- SendBtn.Click += delegate
- {
- WebRequest get = WebRequest.Create("http://186.15.27.24/usersdata.php");
- get.Method = "GET";
- get.Credentials = new NetworkCredential(user, password);
- WebResponse res = get.GetResponse();
- StreamReader io = new StreamReader(res.GetResponseStream(), Encoding.ASCII);
- if (io.ReadToEnd().Contains(NameTxt.Text))
- MessageLabel.Text = "Este usuario ya ha sido registrado";
- else
- MessageLabel.Text = "Este usuario esta disponible";
- };
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement