title: How to check Internet connection in services and as soon as internet is up services should start running
body: <p>Im my app I am writing one service which runs in the background and after every hour it updates the local db in devices as soon as new updates are received and i am sending the status bar notification to the user.</p>
  
  <p>In my services i am making a rest api call but i need to check that if internet connection is down the service for making api calls should not run. I know how to make it in activity but don't know how to do it in the services.</p>
  
  <p><strong>SchedulingService.java</strong></p>
  
  <pre><code>public class SchedulingService extends IntentService {
   DbHandler DbHandler;
   List&lt;Shipment&gt; _shipmentList = new ArrayList&lt;&gt;();
  
  @Override
      protected void onHandleIntent(Intent intent) {
          checkNotificationStatus();
          // Waking up the Alarm Manager after some time
          TrackerAlarmReceiver.completeWakefulIntent(intent);
      }
  
   public void checkNotificationStatus() {
          List&lt;String&gt; notificationList = new ArrayList&lt;String&gt;();
          HashMap&lt;User, String&gt; notificationMap = new HashMap&lt;User, String&gt;();
          UserTracker userTracker;
  
          UserService apiService;
          DbHandler = new DbHandler(this);
          _userList = DbHandler.getAllActiveUsers();
          // Here i am making the API call
          RestAdapter restAdapter = new RestAdapter.Builder()
                  .setEndpoint(ApiMessage.API_URL)
                  .setLogLevel(RestAdapter.LogLevel.FULL)
                  .setConverter(new GsonConverter(new Gson()))
                  .build();
  
          apiService = restAdapter.create(UserService.class);
  
       sendNotification(message);
  }
  </code></pre>