Member-only story

Network Connectivity handling for Android Apps

Attila Akinci
2 min readDec 7, 2021

--

Almost every mobile application in Google Play Store requires network access in order to communicate with servers via REST APIs. Day after day number of the network dependent applications are increasing in stores so network connectivity term is gained much more importance among users and also developers by time.

After announcement of the JetPack Compose’s release, fundamental UI development approaches and practices totally turned into ancient. New declarative UI format (Compose) basically depends on state and it’s changes.

In this article, I am going to show you an useful approach on handling network connectivity in android applications

NetworkConnectivity is a PoC implementation that is part of Android Template repository. All necessary core logics, initial setups and required infrastructures will be provided by AndroidTemplate so we can directly focus on actual topic of ours, Network Connectivity. In order to see details of the template, you can follow the link below 👇 👀

Core Functionality of Network Connectivity 🛜

First thing first, we need decide what will be the capability/boundaries of our “ConnectionManager” that manages network connectivity. In general, having feedback on 3 main states (ConnectionStatus) is enough for my use case.

ConnectionManager is created as a singleton and provides the main logic for defined valid transport types. It starts it’s own coroutine and delivers network state changes asynchronously via connectionStatusFlow.

--

--

Attila Akinci
Attila Akinci

Written by Attila Akinci

Sr. Android Engineer @Booking.com || Software development enthusiast 👨‍💻 / Racing motorcycle addict 🏍️ 🚀 / UAVs ✈️

Responses (1)

Write a response