I have an edge case when pip is enabled and the user wants to search something, the pip will get dismissed(when the user submit a query which has more than one item).
The search component is based on <searchable>
and we used SearchViewListener
to get feedback from the search view component.
@Override
public boolean onQueryTextSubmit(final String query) {
if (!TextUtils.isEmpty(query)) {
saveSearchSelection(query);
fetchSearchResults(query, FULL_RESULTS_LIMIT);
}
return false;
}
When I change the return value to true, the pip is not being dismissed but I get another issue that when you click on back after you clicked on item you will return to the main activity instead of the previous list which is a regression. I was wondering if there is a different solution which won't involve to rewrite the whole search list results just to support pip
Thanks
update
I had today more time to play with the code and I think I found the reason why the pip is closing. We are enabling voice search from
public boolean onCreateOptionsMenu(Menu menu){
//Set up SearchableInfo (need this for voice search)
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(getBaseContext(), UnifiedSearchResultsActivity.class)));
}
when I remove those two lines the pip is not closing and continuing playing without any issues. I was wondering if someone had this issue or knows how to fix it. We are also targeting API level 30.
At the end I managed to fix this issue using the following code
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));