Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we get notified if the phone has got internet access?

Tags:

android

Is there a broadcast receiver or some kind of setting that we can listen/monitor to get notified if the internet/network has been connected.

like image 210
Pentium10 Avatar asked Jun 26 '10 19:06

Pentium10


1 Answers

Listen for CONNECTIVITY_ACTION

This looks like good sample code. Here is a snippet:

        IntentFilter filter = new IntentFilter();
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        context.registerReceiver(mReceiver, filter);
like image 138
drawnonward Avatar answered Oct 22 '22 08:10

drawnonward