Bug 1078182 - "crash in java.lang.NullPointerException: at org.mozilla.search.SearchWidget.addView(SearchWidget.java)" [r=margaret.leibovic]
authorwesj <wjohnston@mozilla.com>
Wed, 08 Oct 2014 12:26:00 -0700
changeset 210100 ef347007fb046389d46713af310a58181a615cd2
parent 210099 c2e81e5b109296f3ab78e0afd342f2181d242e07
child 210101 9901d2c678c7181f86b43b2620881e6f637b0329
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmargaret
bugs1078182
milestone35.0a1
Bug 1078182 - "crash in java.lang.NullPointerException: at org.mozilla.search.SearchWidget.addView(SearchWidget.java)" [r=margaret.leibovic]
mobile/android/search/java/org/mozilla/search/SearchWidget.java
--- 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);
         }