Check Internet connection Android example

public boolean isConnected() {
	 try {
		ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
		 return cm.getActiveNetworkInfo().isConnectedOrConnecting();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		Log.e("isConnected", e.getMessage());
		Toast.makeText(getApplicationContext(), e.getMessage(),
				Toast.LENGTH_LONG).show();
		return false;
	}
This entry was posted in Android Examples Code and tagged , . Bookmark the permalink.


Comments are closed.



2,611 views