Android The application technique of determining network state is more important in practice. So, how does the Android operating system correctly determine if the network we're connected to is disconnected, hmm? Today we will conduct a detailed analysis of this application technique.
Public class Connectionchangereceiver extends
broadcastreceiver
{
@Override
public void OnReceive (context context, Intent Intent)
{
Connectivitymanager connectivitymanage R =
(Connectivitymanager) Context.getsystemservice
(context.connectivity_service); &NBSP
Networkinfo activenetinfo = Connectivitymanager.
Getactivenetworkinfo ();
Networkinfo mobnetinfo = Connectivitymanager.getnetworkinfo
( Connectivitymanager.type_mobile);
if (activenetinfo!= null)
{
Toast.maketext (Context, "Active network Type:" +&NBSP
Activenetinfo.gettypename (), Toast.length_short). Show ();
}
if ( Mobnetinfo!= null)
{
Toast.maketext (Context, "Mobile network Type:" + 
Mobnetinfo.gettyp Ename (), Toast.length_short). Show ();
}
}
}
<!--Needed to check when the NETW ORK Connection ChAnges-->
< Uses-permission android:name= "Android.permission.
Access_network_state "/>
< Receiver android:name=" Com.blackboard.androidtest.
Receiver. Connectionchangereceiver "
android:label=" networkconnection ">&NBSP;
< intent-filter>
< Action android:name= "Android.net.conn.CONNECTIVITY_CHANGE"/>&NBSP;
</intent-filter> &NBSP
</receiver>
The specific application of Android to determine the state of the network is introduced here.