title: Android service not working
body: <p>I'm trying to call a service class to update the value of a variable from my widget but it doesn't ever seem to get to the service class. I've had a look at some examples and I can't figure out what I'm doing wrong, and I don't really know very much about services yet. All help appreciated.</p>
  
  <p>Service class</p>
  
  <pre><code>public class toggleMonitoringService extends Service{
  
      @Override
      public IBinder onBind(Intent intent) {
  
          return null;
      }
  
      @Override
      public void onCreate()
      {
          Log.d("Me","creating service");
          super.onCreate();
      }
  
      @Override
      public int onStartCommand(Intent intent, int startId, int something) {
          // TODO Auto-generated method stub
  
          String toggle = intent.getExtras().getString("Toggle");
          Log.d("Me","Toggle : " + toggle);
          if (toggle.equals("app1"))
          {
              UpdateWidgetService.monitorApp1 = !UpdateWidgetService.monitorApp1;
          }
          else if (toggle.equals("app2"))
          {
              UpdateWidgetService.monitorApp2 = !UpdateWidgetService.monitorApp2;
          }
  
  
          super.onStartCommand(intent, startId, something);
          return 0;
      }
  
  
  
  }
  </code></pre>
  
  <p>Where I set up the intent and pending intent to handle the button click from the widget</p>
  
  <pre><code>    Intent monitor1toggle = new Intent(this.getApplicationContext(),toggleMonitoringService.class);
      monitor1toggle.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
      monitor1toggle.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,allWidgetIds);
      monitor1toggle.putExtra("Toggle","app1");
      PendingIntent monitor1 = PendingIntent.getService(getApplicationContext(), 0 , monitor1toggle,0);
      remoteViews.setOnClickPendingIntent(R.id.firstappstatus, monitor1);
  </code></pre>