2016-11-01 54 views
0

我的Android應用程序與Android 6上的三星鍵盤一起使用時出現問題。當用戶鍵入特殊字符時,如點或星號,下一個鍵被上一個輸入替換焦炭。
實施例:Android鍵盤重複特殊字符

當用戶類型:

mobile.abc 

應用接收:

mobile..bc 

此外,我記錄一個截屏與行爲:youtube video

我的應用程序使用Rhodes/Rhomobile構建,並使用集成的webkit瀏覽器,用戶代理爲:Mozilla/5.0 (Linux; Android 6.0.1; SM-A510M Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/54.0.2840.68 Mobile Safari/537.36

僅當三星鍵盤的預測文本已打開且僅適用於Android 6+時,纔會出現此問題。 我知道它可能是集成的瀏覽器和三星鍵盤之間的不兼容,但我不能要求我的所有用戶關閉它只能用於我的應用程序。所以我想對此有一個解決方法。

預先感謝任何幫助

+0

'提前感謝任何幫助'。當然,凱爾特人當然不會得到幫助。 – greenapps

回答

1

這似乎是一個bug。希望有一個錯誤修正。

在此期間,您可以禁用預測文字是這樣的:

public class NoSuggestionsWebView extends WebView { 
    public NoSuggestionsWebView(Context context) { 
     super(context); 
    } 

    public NoSuggestionsWebView(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public NoSuggestionsWebView(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    @Override 
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) { 
     InputConnection ic = super.onCreateInputConnection(outAttrs); 

     outAttrs.inputType &= ~EditorInfo.TYPE_MASK_VARIATION; /* clear VARIATION type to be able to set new value */ 
     outAttrs.inputType |= InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; /* WEB_PASSWORD type will prevent form suggestions */ 

     return ic; 
    } 
} 

Source

不過,我認爲禁止用於整個應用程序的預測文本會傷害UX。也許你可以在EditorInfo outAttrs找到一些東西來識別有問題的字段?

+0

我沒有訪問這些設置和類,因爲我使用了關閉這些設置的框架。但非常感謝你的幫助。 –

0

該問題是由於尚未修復的Android系統WebView更新引起的。
進一步post on AndroidCentralgabrielmaldi指出,有another post引用該問題。

從第一篇文章開始,WebView版本55.0.2883.36解決了這個問題。