0

When I use inputType as "textUri", Suggestion text input is not displaying.

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter URI"
        **android:inputType="textUri"**
        android:imeOptions="actionDone"/>

</RelativeLayout>

I tried using setPrivateImeOptions method but still suggest text is not displaying. Even I used android:inputType="textUri|textCapSentences|textAutoCorrect" but no use.

  public class CompleteEditTextActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_text);

        EditText editText = findViewById(R.id.editText);
        editText.setPrivateImeOptions("com.android.internal.inputmethod:LatinIME");
    }
3
  • There are hundreds of input method editors (a.k.a., soft keyboards) for Android, including dozens of pre-installed ones. How any react to hints like android:inputType="textUri" is up to their developers. Personally, I would not expect to see suggestions for textUri. Commented Feb 28, 2024 at 13:19
  • It's client requirement to use textUri. Let me know the valid reason/proof why it is not working? @CommonsWare Commented Feb 28, 2024 at 13:50
  • "It's client requirement to use textUri" -- then do not be surprised when some keyboards do not offer suggestions. "Let me know the valid reason/proof why it is not working?" -- the developers of the particular soft keyboard you are testing decided not to offer suggestions for textUri, apparently. That is their right, as the soft keyboard is their project, not yours. You are welcome to test third-party keyboards (on the Play Store, F-Droid, etc.) and see if any happen to offer suggestions for textUri fields. Commented Feb 28, 2024 at 14:11

2 Answers 2

0

It has been identified that the boolean value of shouldSuppressSuggestions has been implemented for TYPE_TEXT_VARIATION_URI in the path

packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/InputAttributes.java

  // TODO: Have a helper method in InputTypeUtils
        // Make sure that passwords are not displayed in {@link SuggestionStripView}.
        final boolean shouldSuppressSuggestions = mIsPasswordField
                || InputTypeUtils.isEmailVariation(variation)
               || **InputType.TYPE_TEXT_VARIATION_URI == variation**
                || InputType.TYPE_TEXT_VARIATION_FILTER == variation
                || flagNoSuggestions
                || flagAutoComplete;
        mShouldShowSuggestions = !shouldSuppressSuggestions;

Hence, When we declare "textURI" in XML, the suggested word on top of the keyboard is not displayed.

Sign up to request clarification or add additional context in comments.

Comments

0

It is not your codding problem its keyboard functionality...

In google Keyboard enable this settings

enter image description here

1 Comment

Even after enabling this suggestion strip, it is not working. Hence it has been identified that, for "textUri", suggestion strip has been disabled in aosp code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.