Compartir a través de


xam.plugins.connectivity - all APIs Sample

transmit

Esteemed Xamarin evangelist James Montemagno ( https://twitter.com/JamesMontemagno ) has a fantastic cross  platform plugin for working with connectivity scenarios in Xamarin. The plugin works with iOS, Windows UWP,
Android, using Forms as well as native targets. The repository has full source code
for the plugin. The repo also has some lightweight samples as well.

As an exploration of the component I've written and shared a sample that takes advantage of
all the APIs in the component I could find.  The sample is available at https://github.com/jhealy/Connectivity-Plugin-Sample  .

Why did I bother building a new sample when James already gave us a sample in his plugins repository?
James's sample is a "IsConnected" detection snippet, but no other APIs are explored. And
there was no Android version. Thus my full on Connectivity Plugin API explorer was conceived.

The sample I've published reacts to status changes. I've supplied iOS, Android, and UWP implementations. Inside we have an enumeration of the following APIs from the Connectivity plugin.

  • IsConnected - Is there an active Internet connection
  • ConnectionStatus changes - React when bandwidth or connection status changes
  • ConnectionTypes - Enumerate available connection types
  • Bandwidths - Enumerate available bandwidths
  • IsReachable - Is machine or URL reachable
  • IsRemoteReachable - Is host by IP or URL reachable

Have fun and enjoy. Feedback is welcome. Tip of the fish to Michael Stonis ( @MichaelStonis ) for
pointing out this component to me.

RESOURCES

Comments

  • Anonymous
    June 22, 2016
    Hi Joe, Great article and thanks for the code.
  • Anonymous
    June 23, 2016
    Helped me get it set up. Thanks!