Whenever a user presses the search button and the SearchView component is shown, it goes back to the button MenuItem once a query is submitted.

However, when a user press the Back key, only the keyboard is hidden but the SearchView component is still visible. If you press the Back key again, one would expect the SearchView to be iconified but the app exits instead.

The workaround for this is to add an OnFocusChangeListener to the SearchView component. Whenever the keyboard gets shown and hidden, the onFocusChange() method gets called.

Here is the code:

Sad to say, there is no workaround if you insist on using ShareActionProvider. Sure, it would definitely look nice if the popup menu for various Share apps will be displayed just below the menu item.

Since there is really no way, the only solution left is to not use ShareActionProvider and use Intent.createChooser() instead.

The results are the same, except that the popup menu will appear at the center of the screen instead of below the menu item in the ActionBar.

And the most important thing is that your icon will look crisp rather than the blurry one.

Here is a sample code.

Related Posts Plugin for WordPress, Blogger...