Use network intents to perform tasks while data is allowed
suggest changeWhen your device connects to a network, an intent is sent. Many apps don’t check for these intents, but to make your application work properly, you can listen to network change intents that will tell you when communication is possible. To check for network connectivity you can, for example, use the following clause:
if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)){ NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); //perform your action when connected to a network }
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents