0

Is there any intent generated when the preferred network is changed on android?

Though WIFI has the higher priority when both Mobile data and WIFI are turned on.but it can be changed using this statement

connectivityManager.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);

However,if I query preferred network immediately after the above statement using

connectivityManager.getNetworkPreference()

I still get ConnectivityManager.TYPE_WIFI as return value.

So it seems that setNetworkPreference doesn't change preferred network immediately.

My question,

Is there any intent generated for change in network preference?

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
rohitverma
  • 767
  • 2
  • 9
  • 14

1 Answers1

0

Create a broadcast receiver listening for:

<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>

See Android, How to handle change in network (from GPRS to Wi-fi and vice-versa) while polling for data for an example.

Community
  • 1
  • 1
userM1433372
  • 5,345
  • 35
  • 38