title: stopService on HTC nullpointerexception
body: <p>in my app, I use an IntentService which I manage from an activity:</p>
  
  <pre><code>    Intent intent = new Intent(this, LogData.class);
      if(isMyServiceRunning()){
          stopService(intent); 
      }else{
          startService(intent);
  
      }...
  
      private boolean isMyServiceRunning() {
          ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
          for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
              if (LogData.class.getName().equals(service.service.getClassName())) {
                  return true;
              }
          }
          return false;
      }
  </code></pre>
  
  <p>I use wakelock and notification in the service, initialized in onStartCommand:</p>
  
  <pre><code>    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
      wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
              "MyBGWakelockTag");
      wakeLock.acquire();
  
  
      Notification noti = new Notification.Builder(this)
      .setContentTitle("Title goes here")
      .setContentText("").setSmallIcon(R.drawable.ic_launcher).build();
  
      notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  
      noti.flags |= Notification.FLAG_ONGOING_EVENT;
  
      notificationManager.notify(0, noti);
  </code></pre>
  
  <p>and close it in onDestroy:</p>
  
  <pre><code>    try{
          if(wakeLock.isHeld()){
              wakeLock.release();
          }
      }catch(Exception e){
          e.printStackTrace();
      }
      notificationManager.cancel(0);
      super.onDestroy();
  </code></pre>
  
  <p>I tested it in some device, it works perfect most of them, but not on HTC One X, it throws a <code>NullpointerException</code>, first on line <code>wakeLock.release()</code>, then I put it in try-catch, now on line <code>notificationManager.cancel(0)</code>. Of course I can put it in try-catch, too, but I don't understand what happens in the background, why this error generated and why just on the HTC? Something close wakelock and notification before my code? Does anyone had same problem, and how can I correct it and close wakelock and notification surely. </p>