直到今天早上我在android studio中运行代码并崩溃时,我的应用程序才能正常运行,我检查了logcat并指出了这两个地方
第一个位于MainActivity.java
的{{1}}
onStart
第二名在我的 mAuth = FirebaseAuth.getInstance();
mToolbar = findViewById(R.id.main_app_bar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("ChatPlus");
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
loadFragment(new RequestFragment());
if (mAuth.getCurrentUser() != null) {
mUserRef = FirebaseDatabase.getInstance().getReference().child("Users").child(mAuth.getCurrentUser().getUid());
}
}
@Override
public void onStart() {
super.onStart(); //crashes here
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
sendtostart();
} else {
mUserRef.child("online").setValue("true");
}
}
@Override
protected void onStop() {
super.onStop();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser != null) {
mUserRef.child("online").setValue(ServerValue.TIMESTAMP);
}
}
RequestFragment