title: Helper Class - Error Unable to start activity ComponentInfo:
body: <p>Error Unable to start activity ComponentInfo: java.lang.IllegalStateException: System services not available to Activities before onCreate()</p>
  
  <p>I´m experimenting with seperating the code and the use of a helper class. (Created different Java files)
  What I did is created an Activity Java file that is registred in the Manifest and I didn´t register this following class (Java file):</p>
  
  <pre><code>import android.app.Activity;
  import android.location.LocationManager;
  import android.net.ConnectivityManager;
  ....
  
  
  public class DeviceMonitor extends Activity {
  
      boolean laag=false;
      int level=-1;
      double batterylevel=-1;
  
  
      public boolean GPSEnabled() {
  
      final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  
      if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) { // NO GPS ENABLED
          //ErrorMessage.append(R.string.enablegps);
          //ErrorMessage.append("\n");
          Log.d("StartPrepare","GPS DISABLED");
          return false;
                      } else {
          Log.d("StartPrepare","GPS ENABLED");
          return true;
                      }
      }
  </code></pre>
  
  <p>I removed the OnCreate() method, is this correct?
  Should I have registred in the Manifest, if yes, how?</p>
  
  <p>I received the following error while calling from the registred Activity like this:</p>
  
  <pre><code>DeviceMonitor MyDevice = new DeviceMonitor();
  if (MyDevice.GPSEnabled()){gpsenabled=true;}else{gpsenabled=false;fout=true;}
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>E/AndroidRuntime(1912): java.lang.RuntimeException: Unable to start
    activity
    ComponentInfo{package}:
    java.lang.IllegalStateException: System services not available to
    Activities before onCreate()</p>
  </blockquote>
  
  <p>Anybody that can give me some light on the helper classes (I´m kind of new in Java/Android) and has any clue what the error can cause? I tried to add the OnCreate() method, but it didn´t help.</p>
  
  <p>Thanks a lot!</p>