title: Android Widget + Service
body: <p>I'm having problems calling a class function from my Widget as the result of a service action.</p>
  
  <pre><code>public class HelloWidget extends AppWidgetProvider {
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager, 
          int[] appWidgetIds) {
  
          Intent intent = new Intent(context, NeoService.class);
          context.startService(intent);
  
          MyClass mClass = new MyClass(context, appWidgetManager);
          mClass.doUpdate();
  
          super.onUpdate(context, appWidgetManager, appWidgetIds);
      }
  }
  </code></pre>
  
  <p>The call to mClass.doUpdate() above works just fine. But then when I try to do it again in my onReceive it doesn't work and I get a forceclose as soon as the correct action is received:</p>
  
  <pre><code>@Override
      public void onReceive(Context context, Intent intent) {
  
       if(Intent.ACTION_TIME_TICK.equals(action))
      {
          mTime.doUpdate();
      //  Toast.makeText(context, "TicK Tock!", Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>If I comment out the mTime.doUpdate(); and uncomment the Toast it displays the toast just fine as it should.</p>
  
  <p>Edit: The error message I get is as follows:</p>
  
  <pre><code>11-18 18:25:00.201: ERROR/AndroidRuntime(2759): FATAL EXCEPTION: main
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.TIME_TICK flg=0x40000004 (has extras) } in de.thesmile.android.widget.HelloWidget@48411298
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:905)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at android.os.Handler.handleCallback(Handler.java:587)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at android.os.Handler.dispatchMessage(Handler.java:92)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at android.os.Looper.loop(Looper.java:123)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at java.lang.reflect.Method.invoke(Method.java:521)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at dalvik.system.NativeStart.main(Native Method)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759): Caused by: java.lang.NullPointerException
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at de.thesmile.android.widget.HelloWidget.onReceive(HelloWidget.java:45)
  11-18 18:25:00.201: ERROR/AndroidRuntime(2759):     at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:892)
  </code></pre>