The application skill of Android to judge the network status is more important in practice. So, in the Android operating system, how can we correctly determine whether the network we are connected to disconnect, eh? Today we will conduct a detailed analysis of this application technique.
1.public class Connectionchangereceiver extends
Broadcastreceiver
0.9
[Email protected]
4.public void OnReceive (context context, Intent Intent)
5.{
6.ConnectivityManager Connectivitymanager =
(Connectivitymanager) Context.getsystemservice
(Context.connectivity_service);
7.NetworkInfo activenetinfo = Connectivitymanager.
Getactivenetworkinfo ();
8.NetworkInfo Mobnetinfo = Connectivitymanager.getnetworkinfo
(Connectivitymanager.type_mobile);
9.if (Activenetinfo! = null)
10. {
11.st.maketext (Context, "Active Network Type:" +
Tivenetinfo.gettypename (), Toast.length_short). Show ();
12.}
Mobnetinfo! = null)
14. {
15.st.maketext (Context, "Mobile Network Type:" +
Bnetinfo.gettypename (), Toast.length_short). Show ();
16.}
17.}
18.}
19.<!--Needed to check when the network connection changes--
20.< uses-permission android:name= "android.permission.
Access_network_state "/>
21.< receiver Android:name= "com.blackboard.androidtest.
Receiver. Connectionchangereceiver "
22.android:label= "Networkconnection" >
23.< intent-filter>
24.< action android:name= "Android.net.conn.CONNECTIVITY_CHANGE"/>
25.</intent-filter>
26.</receiver>
The specific application of Android to determine the status of the network is introduced here. Next, I will introduce you to a more commonly used APP test tool:www.ineice.com
Android Judge Network State method