1. seandroid
  2. Untitled project
  3. frameworks/base

Commits

zobject  committed 686a805

Fix NullpointException problem in onMenuItemSelected

If both title and condensed title is null,
item.getTitleCondensed() could be return null value
in onMenuItemSelected. therefore need to check
whether retun value is null or not.

Change-Id: Ib08f52b949a794aa7bd6cc25414041e820f62969

  • Participants
  • Parent commits bf8de6a
  • Branches master

Comments (0)

Files changed (1)

File core/java/android/app/Activity.java

View file
      * Activity don't need to deal with feature codes.
      */
     public boolean onMenuItemSelected(int featureId, MenuItem item) {
+        CharSequence titleCondensed = item.getTitleCondensed();
+
         switch (featureId) {
             case Window.FEATURE_OPTIONS_PANEL:
                 // Put event logging here so it gets called even if subclass
                 // doesn't call through to superclass's implmeentation of each
                 // of these methods below
-                EventLog.writeEvent(50000, 0, item.getTitleCondensed().toString());
+                if(titleCondensed != null) {
+                    EventLog.writeEvent(50000, 0, titleCondensed.toString());
+                }
                 if (onOptionsItemSelected(item)) {
                     return true;
                 }
                 return false;
                 
             case Window.FEATURE_CONTEXT_MENU:
-                EventLog.writeEvent(50000, 1, item.getTitleCondensed().toString());
+                if(titleCondensed != null) {
+                    EventLog.writeEvent(50000, 1, titleCondensed.toString());
+                }
                 if (onContextItemSelected(item)) {
                     return true;
                 }