Android : 如何跟踪键盘使用情况

Android : How to track Keyboard usage

有没有办法跟踪用户在软键盘上的“速度”?我想知道用户使用键盘所花费的时间。

我希望我的问题很清楚!

您可以在 EditText 中使用文本观察器,并且在每次文本更改时您都可以计算出时间差。

long intialTime=System.getCurrentTimeMillis();
long total = 0;

editText.addTextChangedListener(new TextWatcher() {  
  
            @Override  
            public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {  
                total= total + (System.getCurrentTimeMillis()-initialTime)
                intialTime = System.getCurrentTimeMillis();
            }  
  
            @Override  
            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) 
            {  
               
            }  
  
            @Override  
            public void afterTextChanged(Editable arg0) {  
                
            }  
        });