Permissions
<uses-permission android:name= "Android.permission.INTERNET"/> <uses-permission android:name= " Android.permission.ACCESS_NETWORK_STATE "/>
Maintity
Determine if the network is unblocked plus permissions if (networkutil.isnetavailable (mainactivity.this)) {//Net unblocked //Start request data }else{ Toast.maketext (Mainactivity.this, "Currently no network Check network permissions", 0). Show ();
Networkutil
public class Networkutil {public static Boolean isnetavailable (context context) { //Get network manager Connectivitymanager connm = (Connectivitymanager) Context.getsystemservice (context.connectivity_service); Networkinfo netInfo = Connm.getactivenetworkinfo ();//Get Network details if (NetInfo = = NULL | |!netinfo.isavailable ()) return false; return true; }}
Android to determine whether the network is unblocked and permissions