问题出在setValue(loanedBooks)。在添加此行之前,它工作得很好。 我已经标记了有问题的行。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == RC_SIGN_IN){
if(resultCode == RESULT_OK){
//user logged in
Log.d("AUTH",auth.getCurrentUser().getEmail());
UserInfo user = auth.getCurrentUser();
database.child("users").child(user.getUid()).child("name").setValue(user.getDisplayName());
LoanedBooks loanedBooks = new LoanedBooks();
**database.child("users").child(user.getUid()).child("loaned books").setValue(loanedBooks);** //this is the problem
startActivity(intent_registered);
}
else{
//user not authenticated
Log.d("AUTH","NOT AUTHENTICATED");
}
}
}
LoanedBooks.java类:
public class LoanedBooks {
public ArrayList<AddBook> loanedBooks_list;
DatabaseReference database;
public LoanedBooks(){
loanedBooks_list = new ArrayList<AddBook>();
database = FirebaseDatabase.getInstance().getReference();;
}
public ArrayList<AddBook> getLoanedBooksList(){
return loanedBooks_list;
}
public void addBook(AddBook book){
loanedBooks_list.add(book);
}
}
错误:
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!
E/AndroidRuntime: Error reporting crash
android.os.TransactionTooLargeException