/, General tips/Connectivity checker for mobile, revisited

Connectivity checker for mobile, revisited

Nearly 5 years ago I wrote an article for checking whether a mobile device has an internet connection. This article revisits that solution, dropping the “less-used” functionality, however it also gains an important feature.

The code and demo for this article was written and tested on Delphi Tokyo 10.2.3, however it should work on earlier versions. It relies on units found in the KastriFree project.

In the original article, the main function of the code was to test if the mobile device has an internet connection. This new solution does essentially the same, however it also has an event that is fired when the connectivity changes, i.e. if the internet connection is lost, or becomes connected.

The TConnectivity class has two class methods (i.e. you do not need an instance to call these methods), which are fairly self-explanatory:


It also has an event handler called OnConnectivityChange, which is called when (as you may expect) the internet connectivity changes, passing a Boolean that indicates whether the connection was gained, or lost. On Android, this is achieved by using the MultiReceiver class from the KastriFree project, to receive broadcasts of connectivity changes.

There is also an important difference to the code from the original article regarding iOS: This solution no longer requires the libReachability library, thus resolving the compatibility issues people have been having recently. Many thanks to Horácio Filho for his help in making the Reachability APIs from the System Configuration framework work on Delphi. I may have been floundering for a while longer if it were not for his assistance.

Rather than go into a discussion of the code, I will field questions in the comments.

By |2018-07-15T15:07:05+00:00July 15, 2018 3:07 pm|Code tips, General tips|2 Comments

About the Author:


  1. Erick Suarez July 15, 2018 at 3:24 pm - Reply

    Nice!!! Testing!

  2. Pieter Bas Hofstede September 14, 2018 at 6:14 pm - Reply

    Thanks a lot, just noticed the old solution took 1,5sec on recent iOS devices so had to make the switch to the new solution 🙂

Leave a Reply

Show Buttons
Hide Buttons