title: stopService crashing the app when using Intent Actions
body: <p>I have written a Service that will be running longtime sending location updates on hourly basis to Server. If user doesn't want to send location updates then he will be switching off in the app. So I am starting service (in first Activity) and wanted to stop already running service from a different Activity. So I just declared to actions for the Service in Manifest file as below.</p>
  
  <pre><code>&lt;service android:name=".services.LocationService" android:process=":bgservice"&gt;
      &lt;intent-filter &gt;
         &lt;action android:name="com.example.STOP_LOC_SERVICE"/&gt;
         &lt;action android:name="com.example.START_LOC_SERVICE"/&gt;
     &lt;/intent-filter&gt;  
  &lt;/service&gt;
  </code></pre>
  
  <p>here I want my service to run irrespective of app process so I took a seperate service name by specifying :bgservice. Does this mean my Service is remote service. if so does this create the below issue.</p>
  
  <p>Then using the below code to start and stop the service in the Service class.</p>
  
  <pre><code>@Override
  public int onStartCommand(Intent intent, int flags, int startId) 
  {
      if(intent.getAction().equals("com.example.STOP_LOC_SERVICE"))
      {    // means that you have envoked action that will has to stop the service
                  LocationService.this.stopSelf();   
      }
      else
      {
          return super.onStartCommand(intent, flags, startId);
      }
      return START_STICKY;
  }
  </code></pre>
  
  <p>To Start the Service below lines</p>
  
  <pre><code>Intent istart = new Intent("com.example.START_LOC_SERVICE");
      startService(istart);
  </code></pre>
  
  <p>To Stop the Service below lines</p>
  
  <pre><code>Intent istop = new Intent("com.example.STOP_LOC_SERVICE");
      startService(istop);
  </code></pre>
  
  <p>Everything is working fine on most of the devices. I have tested the service on a variety number of devices. But recently I got a NullPointerException in OnStartCommand() of Service. I am unable to find what is null in that method. Hoping that Intent is null but if intent is null then how a call can be made to service. This issue is not coming on all devices.</p>
  
  <p>Thanks in Advance.</p>
  
  <p>Error is at if loop in onstartcommand</p>
  
  <p>Logcat:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start service com.example.services.LocationService@410e5be8 with null: java.lang.NullPointerException
  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2376)
  at android.app.ActivityThread.access$1900(ActivityThread.java:123)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4424)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
  at com.example.services.LocationService.onStartCommand(LocationService.java:53)
  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2359)
  ... 10 more
  </code></pre>