I'm developing an app. Application restarts when wifi network is switched from netwok-1 to network-2. Problem is that I don't know to detect changing in wifi network. Any help or suggestion would be appreciated.
Asked
Active
Viewed 95 times
0
-
http://stackoverflow.com/a/9463814/1283215 – Hussain Akhtar Wahid 'Ghouri' Oct 21 '13 at 10:02
-
Thanks for replies. Hey guys, i'm asking for the indication of an access point change of the wifi network. So whats your suggestion?? – Sarweshkumar C R Oct 23 '13 at 09:09
1 Answers
0
In general you don't have to take care of the which wifi network is connected, ConnectivityManager will do it on your behalf.
ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();
Now if your app/device(s) changes network state, then you need to monitor the connectivity_change using some broadcast.
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
It'll help you to broadcast only when you've previously suspended updates or downloads in order to resume them.
This tutorial will help you.

Pradip
- 3,189
- 3
- 22
- 27