Bug 1078182 - "crash in java.lang.NullPointerException: at org.mozilla.search.SearchWidget.addView(SearchWidget.java)" [r=margaret.leibovic]
--- a/mobile/android/search/java/org/mozilla/search/SearchWidget.java
+++ b/mobile/android/search/java/org/mozilla/search/SearchWidget.java
@@ -97,18 +97,23 @@ public class SearchWidget extends AppWid
context.startActivity(redirect);
}
super.onReceive(context, intent);
}
// Utility to create the view for this widget and attach any event listeners to it
private void addView(final AppWidgetManager manager, final Context context, final int id, final Bundle options) {
- final int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
- final boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
+ final boolean isKeyguard;
+ if (options != null) {
+ final int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
+ isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
+ } else {
+ isKeyguard = false;
+ }
final RemoteViews views;
if (isKeyguard) {
views = new RemoteViews(context.getPackageName(), R.layout.keyguard_widget);
} else {
views = new RemoteViews(context.getPackageName(), R.layout.search_widget);
addClickIntent(context, views, R.id.search_button, ACTION_LAUNCH_SEARCH);
}