package Ġcom . net char . common . utils Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . net . Network Capabilities Ċ import Ġandroid . os . Build Ċ import Ġandroidx . annotation . Requires Api Ċ import Ġcom . net char . common . extensions . get Connectivity Manager Ċ Ċ enum Ġclass ĠConnect ivity State Ġ{ ĊĠĠĠ ĠCELL ULAR , ĊĠĠĠ ĠW IFI , ĊĠĠĠ ĠVPN , ĊĠĠĠ ĠNONE Ċ } Ċ Ċ object ĠConnect ivity Ġ{ ĊĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġ@ Requires Api ( Build . VERSION _ CODES . M ) ĊĠĠĠ Ġfun Ġis Internet Available ( context : ĠContext ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnetwork State Ġ= Ġget Network State ( context ) ĊĠĠĠĠĠĠĠ Ġreturn Ġnetwork State Ġ!= ĠConnect ivity State . NONE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġ@ Requires Api ( Build . VERSION _ CODES . M ) ĊĠĠĠ Ġfun Ġget Network State ( context : ĠContext ): ĠConnect ivity State Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconnectivity Manager Ġ= Ġcontext . get Connectivity Manager () ĊĠĠĠĠĠĠĠ Ġval Ġactive Network Ġ= Ġconnectivity Manager . active Network Ġ?: Ġreturn ĠConnect ivity State . NONE ĊĠĠĠĠĠĠĠ Ġval Ġnetwork Capabilities Ġ= Ġconnectivity Manager . get Network Capabilities ( active Network ) Ġ?: Ġreturn ĠConnect ivity State . NONE ĊĠĠĠĠĠĠĠ Ġreturn Ġwhen Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Capabilities . has Transport ( Network Capabilities . TRANSPORT _ CELL ULAR ) Ġ-> ĠConnect ivity State . CELL ULAR ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Capabilities . has Transport ( Network Capabilities . TRANSPORT _ WIFI ) Ġ-> ĠConnect ivity State . WIFI ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Capabilities . has Transport ( Network Capabilities . TRANSPORT _ VPN ) Ġ-> ĠConnect ivity State . VPN ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠConnect ivity State . NONE ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } ĊĊ