I am trying to integrate inline autofill suggestions introduced in Android 11 with custom Android Keyboard. I am not getting any inline suggestions in onInlineSuggestionsResponse().
I have added android:supportsInlineSuggestions="true" in input-method xml file.
I have overrided onCreateInlineSuggestionsRequest() in InputMethodService class and created InlineSuggestionRequest as below:
@Nullable
@Override
public InlineSuggestionsRequest onCreateInlineSuggestionsRequest(@NonNull Bundle uiExtras) {
InlinePresentationSpec inlinePresentationSpec = new InlinePresentationSpec.Builder(
new Size(50, 200),
new Size(100,200)
).build();
return new InlineSuggestionsRequest.Builder(
Collections.singletonList(inlinePresentationSpec)
).setMaxSuggestionCount(InlineSuggestionsRequest.SUGGESTION_COUNT_UNLIMITED).setExtras(uiExtras)
.build();
}
I have enabled Google Autofill service and used GBoard to check whether its getting inline suggestion and GBoard was showing autofill inline suggestions.
Also onInlineSuggestionsResponse() is not triggered after onCreateInlineSuggestionsRequest(). What I observed is, onInlineSuggestionsResponse() is called when I navigate from or to the activity containing edittext that request autofill suggestions. It will be called before onCreateInlineSuggestionsRequest().
Is there anything else I should enable in order to get inline Autofill suggestions?