Unable to start service in Android
<p>I made I widget for reading news-items. If I put one widget at my homescreen, everything is fine. But if I put a seconde one at my homescreen and I remove it, the service of the widget stops. So if the widget gets in the update methode, an error occurs.</p>

<pre><code>java.lang.RuntimeException: Unable to start service news.WidgetActivity$UpdateService@405231d8 with Intent { flg=0x10000000 cmp=news/.WidgetActivity$UpdateService bnds=[26,97][79,151] }: java.lang.NullPointerException
</code></pre>

<p>A nullpointer is at this line:</p>

<pre><code>RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
</code></pre>

<p>Here the code:</p>

<pre><code>public static class UpdateService extends Service {
    @Override
    public void onStart(Intent intent, int startId) {

        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);

        remoteViews.setViewVisibility(R.id.WidgetRefresh_btn, View.GONE);
        remoteViews.setViewVisibility(R.id.progressWidget, View.VISIBLE);

        appWidgetManager.updateAppWidget(appWidgetId, remoteViews);

        WidgetActivity.Widget.onUpdate(context, appWidgetManager, appWidgetIds);

    }

    @Override
    public IBinder onBind(Intent arg0) {
        return null;
    }
}   
</code></pre>
