Android 获得;getTextBeforeCursor on inactive InputConnection“;警告信息

Android 获得;getTextBeforeCursor on inactive InputConnection“;警告信息,android,Android,下面是我实现的DeviceAdminReceiver子类的代码片段:- public void onDisabled(Context context, Intent intent) { super.onDisabled(context, intent); AntiTheftApplicationContext.setApplicationContext( context.getApplicationContext()); final Context

下面是我实现的DeviceAdminReceiver子类的代码片段:-

public void onDisabled(Context context, Intent intent) 
{
    super.onDisabled(context, intent);

    AntiTheftApplicationContext.setApplicationContext(
        context.getApplicationContext());

    final Context applicationContext =  AntiTheftApplicationContext.
        getApplicationContext();

    Thread thread = new Thread(new Runnable() 
    {
        @Override
        public void run() 
        {
            applicationContext.stopService(new Intent(applicationContext,    AuthenticationWakeupCallReceiver.class));

            applicationContext.startService(new Intent(applicationContext, AuthenticationWakeupCallReceiver.class));

        }
    });

    thread.start();

    while(AntiTheftUtil.isMyServiceRunning(
           AuthenticationWakeupCallReceiver.class.getName()))
    {
        try 
        {
            Thread.sleep(20000);
        } 
        catch (InterruptedException e) 
        {
            e.printStackTrace();
        }
     }
}
AuthenticationWakeupCallReceiver启动另一个活动,即PostStartupAuthenticationActivity:-

if(!PostStartupAuthenticationActivity.isActivityRunning())
{
    Intent intent = new Intent(context,XYZ.class);

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    context.startActivity(intent);
}
XYZ活动包含一个EditText,在布局文件中定义如下:-

<EditText
    android:id="@+id/re_enter_authentication_code"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="enter authentication code"
    android:inputType="textPassword"
    android:maxLines="1"
    android:singleLine="true" />
问题1:- 但当从AuthenticationWakeupCallReceiver调用XYZ时,XYZ活动中定义的EditText停止接受数字。当我输入简单字母时,它被接受,但当我输入数字时,它不被接受。我收到以下警告消息:-“GetTextBeforeCursoron inactive InputConnection”

问题2:- 我正在寻找一种更好的方法,我想从DeviceAdminReceiver子类调用一个活动,而不用启动另一个线程来检查我的服务的运行状态。我可以在不启动单独线程的情况下启动活动吗。我只想在验证用户之前阻止控制流。DeviceAdminReceiver子类中的onDisabled方法应仅在正确验证用户后才能完成执行

final EditText dataEnteredEditText = (EditText)findViewById(R.id.re_enter_authentication_code);

TextWatcher watcher = new TextWatcher() 
{
    int countAttempts = 0;

    @Override
    public void onTextChanged(CharSequence enteredText, int start, int before, int count) 
    {
        String value = enteredText.toString();

        if(value.length() >= authenticationCode.length() &&       !value.equals(authenticationCode))
        {
            dataEnteredEditText.setError("Invalid Code!!!");

            dataEnteredEditText.setText(AntiTheftConstants.EMPTY_STRING);

            countAttempts++;

            if(countAttempts == 3)
            {
                SharedPreferences.Editor editor = sharedPref.edit();

                editor.putBoolean(AntiTheftConstants.USER_AUTHENTICATION_STATUS, false);

                editor.commit();            

                startProcessForAuthenticationFailure();

                finish();
//          }
        }
        else if(value.equals(authenticationCode))
        {
            mIsCorrectPasswordEntered = true;

            stopService(new Intent(AntiTheftApplicationContext.getApplicationContext(), AuthenticationWakeupCallReceiver.class));

            stopService(new Intent(AntiTheftApplicationContext.getApplicationContext(), AuthenticationWakeupCallReceiver.class));

            notifySuccessfulAuthentication();
       }
    }
}