Advertisement
Guest User

Untitled

a guest
Jan 8th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. namespace App1
  2. {
  3.     [Activity(Label = "App1", MainLauncher = true)]
  4.     public class MainActivity : Activity
  5.     {
  6.         protected override void OnCreate(Bundle savedInstanceState)
  7.         {
  8.             base.OnCreate(savedInstanceState);
  9.  
  10.             // Set our view from the "main" layout resource
  11.             SetContentView(Resource.Layout.Main);
  12.  
  13.             // Get the latitude/longitude EditBox and button resources:
  14.             String UserName = FindViewById<EditText>(Resource.Id.UserName).Text;
  15.             String UserEmail = FindViewById<EditText>(Resource.Id.UserEmail).Text;
  16.             String UserPassword = FindViewById<EditText>(Resource.Id.UserPassword).Text;
  17.             Button LoginButton = FindViewById<Button>(Resource.Id.LoginButton);
  18.  
  19.             // When the user clicks the button ...
  20.             LoginButton.Click += async (sender, e) =>
  21.             {
  22.                 //On button click it will run a url to see if the user can log in, if not will be prompted to register
  23.                 LoginUser(UserName, UserEmail, UserPassword);
  24.             };
  25.         }
  26.  
  27.         //Create new methods here
  28.  
  29.         //Create a Client here for HTTP services and share in app
  30.         private static readonly HttpClient client = new HttpClient();
  31.  
  32.         // Gets weather data from the passed URL.
  33.         private void LoginUser(String UserName, String UserEmail, String UserPassword)
  34.         {
  35.             {
  36.                 Uri uri = new Uri("http://192.168.0.104:5000/create_user/ " + UserName + "/" + UserEmail + "/" +  UserPassword );
  37.                 WebRequest webRequest = WebRequest.Create(uri);
  38.                 WebResponse response = webRequest.GetResponse();
  39.                 Console.WriteLine(((HttpWebResponse)response).StatusDescription);
  40.                 Stream data = response.GetResponseStream();
  41.                 Console.Write(data);
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement