Skip to content

Commit

Permalink
Avoid crash if "Search Service" isn't available
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitsaibot authored and jspricke committed May 4, 2024
1 parent b3286f2 commit f6f87ab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/com/android/calendar/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1429,9 +1429,13 @@ public static void returnToCalendarHome(Context context) {
* @param act The activity using the view
*/
public static void setUpSearchView(SearchView view, Activity act) {
SearchManager searchManager = (SearchManager) act.getSystemService(Context.SEARCH_SERVICE);
view.setSearchableInfo(searchManager.getSearchableInfo(act.getComponentName()));
view.setQueryRefinementEnabled(true);
try {
SearchManager searchManager = (SearchManager) act.getSystemService(Context.SEARCH_SERVICE);
view.setSearchableInfo(searchManager.getSearchableInfo(act.getComponentName()));
view.setQueryRefinementEnabled(true);
} catch (Exception e) {
Log.d(TAG, "Search Service not found");
}
}

/**
Expand Down

0 comments on commit f6f87ab

Please sign in to comment.