java.lang.Throwable:setStateLocked

时间:2016-10-11 00:32:02

标签: java android throwable

每次从其他活动意图到LoginActivity,它都会崩溃应用程序。

错误的Logcat:

  

AccessibilityManager:setStateLocked:wasEnabled = false,mIsEnabled =   false,wasTouchExplorationEnabled = false,mIsTouchExplorationEnabled   = false,wasHighTextContrastEnabled = false,mIsHighTextContrastEnabled = false                                                                                          java.lang.Throwable:setStateLocked at   com.example.feoit.mapmanagement.LoginActivity.onCreate(LoginActivity.java:63)

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {

    EditText email, password;
    Button btnSignIn, forgotpwdbtn, btnRegister;
    private FirebaseAuth auth;


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


        email = (EditText) findViewById(R.id.email);
        password = (EditText) findViewById(R.id.password);

        btnSignIn = (Button) findViewById(R.id.btnSignIn);
        forgotpwdbtn = (Button) findViewById(R.id.forgotpwdbtn);
        btnRegister = (Button) findViewById(R.id.btnRegister);

        btnSignIn.setOnClickListener(this);
        forgotpwdbtn.setOnClickListener(this);
        btnRegister.setOnClickListener(this);

        auth = FirebaseAuth.getInstance();
    }



    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btnSignIn:
                String email1 = email.getText().toString().trim();
                String password1 = password.getText().toString().trim();
                auth.signInWithEmailAndPassword(email1, password1).addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {

                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {

                        if (task.isSuccessful()) {
                            Toast.makeText(LoginActivity.this, "Authentication success", Toast.LENGTH_SHORT).show();
                            Intent mainIntent = new Intent(LoginActivity.this, MapsTrack.class);
                            startActivity(mainIntent);

                        } else {
                            Toast.makeText(LoginActivity.this, "Authentication failed." + task.getException(), Toast.LENGTH_SHORT).show();
                        }
                    }
                });
                break;
            case R.id.forgotpwdbtn:
                Intent intent = new Intent(LoginActivity.this, ForgotPasswordActivity.class);
                startActivity(intent);
                break;
            case R.id.btnRegister:
                Intent intentreg = new Intent(LoginActivity.this, Register.class);
                startActivity(intentreg);
                break;


        }
    }
}

该班的第63行是

setContentView(R.layout.activity_login);

完整的logcat错误:

  

AccessibilityManager:setStateLocked:wasEnabled = false,mIsEnabled = false,wasTouchExplorationEnabled = false,mIsTouchExplorationEnabled = false,wasHighTextContrastEnabled = false,mIsHighTextContrastEnabled = false                                                                                          java.lang.Throwable:setStateLocked                                                                                              在android.view.accessibility.AccessibilityManager.setStateLocked(AccessibilityManager.java:553)                                                                                              在android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:636)                                                                                              在android.view.accessibility.AccessibilityManager。(AccessibilityManager.java:226)                                                                                              在android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:206)                                                                                              在android.view.View.setFlags(View.java:9920)                                                                                              在android.view.ViewGroup.initViewGroup(ViewGroup.java:536)                                                                                              在android.view.ViewGroup。(ViewGroup.java:525)                                                                                              在android.view.ViewGroup。(ViewGroup.java:520)                                                                                              在android.view.ViewGroup。(ViewGroup.java:516)                                                                                              在android.view.ViewGroup。(ViewGroup.java:512)                                                                                              在android.widget.FrameLayout。(FrameLayout.java:119)                                                                                              在com.android.internal.policy.impl.PhoneWindow $ DecorView。(PhoneWindow.java:2330)                                                                                              在com.android.internal.policy.impl.PhoneWindow.generateDecor(PhoneWindow.java:3471)                                                                                              在com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3857)                                                                                              在com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:2046)                                                                                              在android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:367)                                                                                              在android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:316)                                                                                              在android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:281)                                                                                              在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)                                                                                              在com.example.feoit.mapmanagement.LoginActivity.onCreate(LoginActivity.java:63)                                                                                              在android.app.Activity.performCreate(Activity.java:6092)                                                                                              在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)                                                                                              在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514)                                                                                              在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)                                                                                              在android.app.ActivityThread.access $ 800(ActivityThread.java:182)                                                                                              在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1515)                                                                                              在android.os.Handler.dispatchMessage(Handler.java:111)                                                                                              在android.os.Looper.loop(Looper.java:194)                                                                                              在android.app.ActivityThread.main(ActivityThread.java:5717)                                                                                              at java.lang.reflect.Method.invoke(Native Method)                                                                                              在java.lang.reflect.Method.invoke(Method.java:372)                                                                                              在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:959)                                                                                              在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

2 个答案:

答案 0 :(得分:2)

显然,我找到了解决方案。我错过了一个活动中的super.onStop(),这对我来说是粗心的。道歉并感谢您的所有时间!

答案 1 :(得分:0)

这可能是您从mainActivity尝试登录活动的调用意图的方式,或者您尝试创建我通常使用的意图的方式

Intent i = new Intent(this, Page2.class); // Change to LoginActivity.class
i.putExtra("isNewUser","true"); // Optional 
startActivity(i);

您可能已经这样做了,我不确定您的代码是否包含在内。

此外,您应该在switch语句中添加一个默认大小写,它可以防止棘手的错误。