Code example for NetworkInfo

Methods: getDetailedStategetReasongetSubtypeNamegetTypegetTypeNameisAvailableisConnected

0
			public void onClick(View arg0) 
			{ 
				ConnectivityManager  cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
				NetworkInfo info = cm.getActiveNetworkInfo();
				 
				if((info!=null)&&(info.isAvailable())&&(info.isConnected()))
				{ 
					String k="\n Type Name: "+info.getTypeName();
					k+="\n Detailed State : "+info.getDetailedState();
					k+="\n Reason: "+info.getReason();
					k+="\n Sub Types: "+info.getSubtypeName();
					k+="\n Type: "+info.getType();	
					Toast.makeText(Download.this,"Connection Exists : \n"+k ,Toast.LENGTH_LONG).show();
					Log.d("Infor. : ","info: "+k);
				} 
				else 
					Toast.makeText(Download.this,"Connection Not Exists" ,Toast.LENGTH_LONG).show();
			} 
		}); 
         
Experience pair programming with AI  Get Codota for Java