Guest User

Untitled

a guest
Jul 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  4. xmlns:local="clr-namespace:TBSApplication"
  5. x:Class="TBSApplication.MainPage">
  6. <ContentPage.Content>
  7. <ScrollView>
  8. <StackLayout>
  9. <Button x:Name="Btn" Text="Check Connectivity" Clicked="Btn_Clicked"/>
  10. <Label x:Name="Lbl" Text="Status"/>
  11. <Label x:Name="Lbl1" Text="Type:"/>
  12. </StackLayout>
  13. </ScrollView>
  14. </ContentPage.Content>
  15. </ContentPage>
  16.  
  17. using Plugin.Connectivity;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Diagnostics;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Threading.Tasks;
  24. using Xamarin.Forms;
  25.  
  26. namespace TBSApplication
  27. {
  28. public partial class MainPage : ContentPage
  29. {
  30. public MainPage()
  31. {
  32. InitializeComponent();
  33. }
  34.  
  35. private void Btn_Clicked(object sender, EventArgs e)
  36. {
  37. try
  38. {
  39. var isConnected = CrossConnectivity.Current.IsConnected;
  40.  
  41. if (isConnected == true)
  42. {
  43. DisplayAlert("Message", "Connected", "Ok");
  44. }
  45. else
  46. {
  47. DisplayAlert("Message", "Not Connected", "Ok");
  48. }
  49. }
  50. catch (System.Exception ex)
  51. {
  52. DisplayAlert("Message", ex.Message, "Ok");
  53. }
  54. }
  55. }
  56. }
Add Comment
Please, Sign In to add comment