Code example for Service

Methods: getSystemService

0
	 *            - current activity 
	 * @return boolean - true: network available; false: no network 
	 */ 
	public boolean checkNetworkAvailability(Service service) {
 
		ConnectivityManager cManager = (ConnectivityManager) service.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo nInfo = cManager.getActiveNetworkInfo();
		if (nInfo == null || !nInfo.isConnected()) {
			return false; 
		} else { 
			return true; 
		} 
 
	} 
 
	@Override 
	public void onDestroy() { 
		super.onDestroy(); 
		this.isThreadDisabled = true;
	} 
}