title: Context is null in service constructor?
body: <p>My goal is to have a background service that update a fairly large amount of data twice a day (~5min update, possibly more).</p>
  
  <p>So I have a GcmTaskService that launch this service : </p>
  
  <pre><code>public class SyncOfflineCoursesService extends Service {
  
      private final IBinder mBinder = new MonBinder();
      private final SharedPreferenceManagerToReplace sharedPreferenceManager;
  
      public SyncOfflineCoursesService() {
  
          sharedPreferenceManager = new SharedPreferenceManagerToReplace(this); //crash on this line
  
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
      ...
      }
  
      @Override
      public IBinder onBind(Intent intent) {
          return mBinder;
      }
  
      public class MonBinder extends Binder {
          SyncOfflineCoursesService getService() {
              return SyncOfflineCoursesService.this;
          }
      }
  
  }
  </code></pre>
  
  <p><code>SharedPreferenceManagerToReplace</code> : </p>
  
  <pre><code>public class SharedPreferenceManagerToReplace {
      private final SharedPreferences prefs;
  
      public SharedPreferenceManagerToReplace(Context context) {
          this.prefs = PreferenceManager.getDefaultSharedPreferences(context);//crash here
      }
  }
  </code></pre>
  
  <p>but it seem that this is null when I instanciate <code>SharedPreferenceManager</code></p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
  </code></pre>
  
  <p>That's how I declared both of my services in my manifest : </p>
  
  <pre><code>&lt;service
      android:name=".service.offline.SyncOfflineCoursesService"
      android:exported="false" /&gt;
  
  &lt;service
      android:name=".service.offline.SyncOfflineContentService"
      android:exported="true"
      android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"&gt;
  
      &lt;intent-filter&gt;
          &lt;action android:name="com.google.android.gms.gcm.ACTION_TASK_READY" /&gt;
      &lt;/intent-filter&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>Would you have an idea ?</p>
  
  <p>Thanks !</p>