Android Widget PendingIntent Fails
<p>There have been some similar issues discussed here, but my situation does work some of the time. I am developing a widget that when clicked should launch an activity that's part of the same package. This same activity can also be launched by a notification that may be posted. The widget updates and notification posting are done by a Service in the package. Here is the method that's called to issue the PendingIntent:</p>

<pre><code>// Get pending intent for widget or notification
private PendingIntent getPendingIntent(int widgetId, int extraData) {
    Intent clickIntent = new Intent(mCtx, OtdShowEvents.class);
    clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    clickIntent.putExtra("OTDExtra", extraData);
    clickIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendIntent = PendingIntent.getActivity(mCtx, 0, clickIntent, 
            0);
    return pendIntent;
}
</code></pre>

<p>If I create an instance of the widget on a clean (rebooted) device, both the widget and notification launch the target activity as expected. However, if I remove the widget and create another instance, the Intent is no longer launched. Likewise, if I uninstall the widget altogether, then re-install it and create an instance, no Intent is fired off. However, if I power off and back on (leaving the widget in place), it works again when booted up.</p>

<p>One error that I saw along the way was from the PackageManager saying "Name not found", but indicating the package name "com.ghcssoftware.OTD.full", which is the correct name of my package!</p>

<p>Any ideas? And by the way, I have tried some of the PendingIntent flags such as FLAG_CANCEL_CURRENT and FLAG_UPDATE_CURRENT without affecting this behavior.</p>

<p>FWIW, I found that the code snippet provided in this article was exactly what I needed to figure out how to get this all working correctly, especially for multiple instances of my widget, etc.: <a href="http://stackoverflow.com/questions/2706303/pendingintent-in-widget-taskkiller">PendingIntent in Widget + TaskKiller</a></p>
