Final telephonymanager mtelephonymgr = (telephonymanager) getsystemservice (context. telephony_service); mtelephonymgr. listen (New phonestatelistener () {@ override public void ondataconnectionstatechanged (INT state) {Switch (state) {Case telephonymanager. data_disconnected: // The network is disconnected from the system. out. println ("Network disconnected 1"); toast. maketext (mainuihomepage. this, "Network disconnected! ", Toast. length_long ). show (); break; Case telephonymanager. data_connecting: // The network is connecting to the system. out. println ("Network disconnected 2"); toast. maketext (mainuihomepage. this, "the network is connected... ", toast. length_long ). show (); break; Case telephonymanager. data_connected: // system connected to the network. out. println ("Network disconnected 3"); toast. maketext (mainuihomepage. this, "the network is connected! ", Toast. length_long). Show (); break ;}}, phonestatelistener. listen_data_connection_state );