Check for Internet Connection in the Android Application.

Mobile Apps Development A-Z Guide.

Volodymyr Babenko
Pharos Production
2 min readJan 29, 2019

--

Give us a message if you’re interested in Blockchain and FinTech software development or just say Hi at Pharos Production Inc.

Or follow us on Youtube to know more about Software Architecture, Distributed Systems, Blockchain, High-load Systems, Microservices, and Enterprise Design Patterns.

Pharos Production Youtube channel

The most frequent use of background services in Android applications is to update information. Accordingly, they will not be able to be accomplished Tasks of this type require an internet connection. It is also useful to inform the user about communication problems.

Step 1.

To start, you need to add into AndroidManifest network access permission.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Step 2.

To obtain information about the current state of the connection, use the ConnectivityManager system service.

Step 3.

Network status changes will be monitored with Broadcast Receiver.

Step 4.

Add register receiver in AndroidManifest.

Step 5.

Apps targeting Android 7.0 (API level 24) and higher do not receive broadcasts if they declare the broadcast receiver in their manifest. Apps will still receive broadcasts if they are registered with Context.registerReceiver() and that context is still valid.

Follow the link below to find a full example:

That you for reading!

--

--