package Ġcom . d roid fort . nw ds ample Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . constraint layout . widget . Constraint Layout Ċ import Ġcom . d roid fort . net detector . Network ChangeListener Ċ import Ġcom . d roid fort . net detector . Network Detector Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity (), ĠNetwork ChangeListener Ġ{ ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ main ) ĊĊĠĠĠĠĠĠĠ ĠNetwork Detector . init ( this ) ĊĠĠĠĠĠĠĠ ĠNetwork Detector . getInstance (). add Network ChangeListener ( this ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġoverride Ġfun Ġon Network ChangeListener ( is Network Available : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġconstraint layout : Constraint Layout Ġ= ĠfindViewById ( R . id . constraint layout ) ĊĠĠĠĠĠĠĠ ĠNetwork Detector . getInstance (). show Sn ackBar ( constraint layout , is Network Available ) ĊĠĠĠ Ġ} Ċ } Ċ