How to disable displaying "suggestions" on the Soft Keyboard

I want to turn off displaying "Suggested Words" on the soft/virtual keyboard when someone is using my application (only on certain Activities). For the default Android keyboard, this can be found under 'Settings' (under Word Suggestion Settings).

Is there a way to disable it only within your application, without requiring the user to manually go and do it? I basically want the user to type words without providing any hints.

Thanks!


Solution 1:

When developing for 2.0+, the supposed way is setting android:inputType="textNoSuggestions" (ref). Unfortunately, suggestions are still shown on HTC Desire 2.2 (and probably other HTC Sense devices as well).
Using android:inputType="textVisiblePassword"will not help as well as the software keyboard by HTC won't allow you to switch languages.
So I stick to android:inputType="textFilter" to disable suggestions.

Solution 2:

You can disable suggestions on the Soft Keyboard by adding the following line in the xml -

android:inputType="textNoSuggestions"

However according to this article, it may or may not be supported by the IME (the keyboard).

If this issue occurs, the below method works for sure -

android:inputType="textNoSuggestions|textVisiblePassword"

Solution 3:

This works for me with the stock keyboard, even on HTC with 2.2

final EditText et = (EditText) findViewById(R.id.SearchText);
et.setInputType(et.getInputType()
    | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS
    | EditorInfo.TYPE_TEXT_VARIATION_FILTER);

Solution 4:

On my 6P running Nougat, nothing worked. While it is empty the suggestion bar stays up because it has the microphone icon on the right side. In order to get rid of that, I used fingerup's suggestion in one of the comments and it worked! So I decided to write an actual answer so people don't miss it. To recap here's what I've used:

    android:inputType="textNoSuggestions|textFilter|textVisiblePassword"
    android:privateImeOptions="nm"

inputType="textNoSuggestions|textFilter|textVisiblePassword" prevents suggestions, and privateImeOptions="nm" (stands for "no microphone") prevents the bar from showing up because it still would since the mic button is in it. So it is necessary to use both attributes because if all you do is specify no mic then the bar still shows up with recommendations.
Thx again to fingerup for mentioning the nm trick. ;)