-
public interface StreamAndroidComponentsProviderFacade over the Android system services required by the core SDK.
Abstracting the access behind this interface allows Stream components to operate in tests, host-apps with custom dependency wiring, or alternative runtime environments.
val components = StreamAndroidComponentsProvider(context) val connectivity = components.connectivityManager().getOrNull() val lifecycle = components.lifecycle()
-
-
Method Summary
Modifier and Type Method Description abstract Result<ConnectivityManager>connectivityManager()Retrieves the ConnectivityManager system service. abstract Result<WifiManager>wifiManager()Retrieves the WifiManager system service. abstract Result<TelephonyManager>telephonyManager()Retrieves the TelephonyManager system service. abstract Lifecyclelifecycle()Retrieves the Lifecycle for the application. -
-
Method Detail
-
connectivityManager
abstract Result<ConnectivityManager> connectivityManager()
Retrieves the ConnectivityManager system service.
val connectivity: ConnectivityManager = components.connectivityManager().getOrElse { throwable -> logger.e(throwable) { "Connectivity unavailable" } throw throwable }
-
wifiManager
abstract Result<WifiManager> wifiManager()
Retrieves the WifiManager system service.
val isWifiEnabled = components.wifiManager() .map { wifi -> wifi.isWifiEnabled } .getOrDefault(false)
-
telephonyManager
abstract Result<TelephonyManager> telephonyManager()
Retrieves the TelephonyManager system service.
val networkType = components.telephonyManager() .map { telephony -> telephony.dataNetworkType } .getOrElse { TelephonyManager.NETWORK_TYPE_UNKNOWN }
-
-
-
-