获取'E / AndroidRuntime:错误报告崩溃android.os.TransactionTooLargeException'点击AlertDialog的正面按钮 [英] Getting 'E/AndroidRuntime: Error reporting crash android.os.TransactionTooLargeException' on clicking a Positive button of AlertDialog
问题描述
E / AndroidRuntime:错误报告崩溃android.os.TransactionTooLargeException
这也是:
java.lang.StackOverflowError:堆栈大小8MB
在给定的代码下运行:
mAuthListener = new FirebaseAuth.AuthStateListener(){
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth){
final FirebaseUser user = firebaseAuth.getCurrentUser();
if(user!= null){
//用户登录
if(isFacebookLoggedIn()){
if(dialog == null){
最后AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
LayoutInflater inflater =(LayoutInflater)getBaseContext()。getSystemService(Context.LAYOUT_INFLATER_SERVICE);
查看alertDialogView = inflater.inflate(R.layout.choose_unique_name_dialog,null);
uniqueUserName =(EditText)alertDialogView.findViewById(R.id.uniqueUserName);
usernameChoosen =(TextView)alertDialogView.findViewById(R.id.usernameChoosen);
usernameWarning =(TextView)alertDialogView.findViewById(R.id.usernameWarning);
usernameChoosen.setVisibility(View.INVISIBLE);
usernameWarning.setVisibility(View.INVISIBLE);
builder.setTitle(选择一个唯一的用户名);
builder.setView(alertDialogView);
builder.setPositiveButton(Continue,new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface,int i){
}
});
dialog = builder.create();
}
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
wantToCloseDialog = false;
//做东西,可能将wantToCloseDialog设置为true然后...
if(uniqueUserName.getText()。toString()。isEmpty()){
Toast.makeText(getBaseContext (),请选择一个唯一的用户名,Toast.LENGTH_LONG).show();
wantToCloseDialog = false;
} else {
mDatabase.child(用户名)。addValueEventListener(new ValueEventListener(){
@Override
如果(dataSnapshot.getValue()。toString()。)包含(uniqueUserName.getText()。toString() )){
Toast.makeText(getBaseContext(),uniqueUserName.getText()。toString()+已被采纳,Toast.LENGTH_LONG).show();
usernameChoosen.setText(uniqueUserName.getText()。toString());
wantToCloseDialog = false;
} else {
//执行此代码时发生错误
Log.d(signedIn,onAuthStateChanged:signed_in:+ user。的getuid());
mDatabase.child(users)。child(user.getUid())。child(name)。setValue(user.getDisplayName());
mDatabase.child(users)。child(user.getUid())。child(imageUID)。setValue(user.getPhotoUrl());
mDatabase.child(users)。child(user.getUid())。child(uniqueUserName)。setValue(uniqueUserName.getText()。toString());
mDatabase.child(users)。child(user.getUid())。child(followers)。setValue(00);
mDatabase.child(users)。child(user.getUid())。child(following)。setValue(00);
mDatabase.child(unique-usernames)。child(ts).setValue(uniqueUserName.getText()。toString());
Intent mainIntent = new Intent(SignUpActivity.this,SplashActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
progressDialog.setMessage(注册...);
progressDialog.setCancelable(false);
progressDialog.show();
wantToCloseDialog = true;
}
} else {
Log.d(signedIn,onAuthStateChanged:signed_in:+ user.getUid());
mDatabase.child(users)。child(user.getUid())。child(name)。setValue(user.getDisplayName());
mDatabase.child(users)。child(user.getUid())。child(imageUID)。setValue(user.getPhotoUrl());
mDatabase.child(users)。child(user.getUid())。child(uniqueUserName)。setValue(uniqueUserName.getText()。toString());
mDatabase.child(users)。child(user.getUid())。child(followers)。setValue(00);
mDatabase.child(users)。child(user.getUid())。child(following)。setValue(00);
mDatabase.child(unique-usernames)。child(ts).setValue(uniqueUserName.getText()。toString());
Intent mainIntent = new Intent(SignUpActivity.this,SplashActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
progressDialog.setMessage(注册...);
progressDialog.setCancelable(false);
progressDialog.show();
wantToCloseDialog = true;
$ b @Override
public void onCancelled(DatabaseError databaseError){
Snackbar snackbar = Snackbar
.make(coordinatorLayout,databaseError.getMessage() ,Snackbar.LENGTH_LONG);
snackbar.show();
wantToCloseDialog = false;
}
});
if(wantToCloseDialog)
dialog.dismiss();
//其他对话框保持打开状态。确保你有一个明显的方法来关闭对话框,特别是如果你设置可以取消为false。
}
});
} else {
Log.d(signedIn,onAuthStateChanged:signed_in:+ user.getUid());
mDatabase.child(users)。child(user.getUid())。child(name)。setValue(userName.getText()。toString());
mDatabase.child(users)。child(user.getUid())。child(uniqueUserName)。setValue(uniqueUserName.getText()。toString());
mDatabase.child(users)。child(user.getUid())。child(followers)。setValue(00);
mDatabase.child(users)。child(user.getUid())。child(following)。setValue(00);
mDatabase.child(unique-usernames)。child(ts).setValue(uniqueUserName.getText()。toString());
Intent mainIntent = new Intent(SignUpActivity.this,SplashActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
progressDialog.dismiss();
$ b} else {
//用户签出
Log.d(signedOut,onAuthStateChanged:signed_out);
}
// ...
}
};
我从来没有见过这样的错误,所以我不知道这里发生了什么。 p>
请让我知道是什么原因造成这个错误!
$ b $在深入代码至少10-12次之后,我得到了这个问题。 b
解决方法是在 user.getPhotoUrl()
中添加 .toString()
这行代码: mDatabase.child(users)。child(user.getUid())。child(imageUID)。setValue(user.getPhotoUrl());
现在已经解决了!
I'm getting this error:
E/AndroidRuntime: Error reporting crash android.os.TransactionTooLargeException
and this too:
java.lang.StackOverflowError: stack size 8MB
while running below given code:
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
final FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
if (isFacebookLoggedIn()) {
if (dialog == null) {
final AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View alertDialogView = inflater.inflate(R.layout.choose_unique_name_dialog, null);
uniqueUserName = (EditText) alertDialogView.findViewById(R.id.uniqueUserName);
usernameChoosen = (TextView) alertDialogView.findViewById(R.id.usernameChoosen);
usernameWarning = (TextView) alertDialogView.findViewById(R.id.usernameWarning);
usernameChoosen.setVisibility(View.INVISIBLE);
usernameWarning.setVisibility(View.INVISIBLE);
builder.setTitle("Choose a unique username");
builder.setView(alertDialogView);
builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
dialog = builder.create();
}
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wantToCloseDialog = false;
//Do stuff, possibly set wantToCloseDialog to true then...
if (uniqueUserName.getText().toString().isEmpty()) {
Toast.makeText(getBaseContext(), "Please choose a unique username", Toast.LENGTH_LONG).show();
wantToCloseDialog = false;
} else {
mDatabase.child("unique-usernames").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.getValue() != null) {
if (dataSnapshot.getValue().toString().contains(uniqueUserName.getText().toString())) {
Toast.makeText(getBaseContext(), uniqueUserName.getText().toString() + " is already taken", Toast.LENGTH_LONG).show();
usernameChoosen.setText(uniqueUserName.getText().toString());
wantToCloseDialog = false;
} else {
// error is happening on execution of this code
Log.d("signedIn", "onAuthStateChanged:signed_in:" + user.getUid());
mDatabase.child("users").child(user.getUid()).child("name").setValue(user.getDisplayName());
mDatabase.child("users").child(user.getUid()).child("imageUID").setValue(user.getPhotoUrl());
mDatabase.child("users").child(user.getUid()).child("uniqueUserName").setValue(uniqueUserName.getText().toString());
mDatabase.child("users").child(user.getUid()).child("followers").setValue("00");
mDatabase.child("users").child(user.getUid()).child("following").setValue("00");
mDatabase.child("unique-usernames").child(ts).setValue(uniqueUserName.getText().toString());
Intent mainIntent = new Intent(SignUpActivity.this, SplashActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
progressDialog.setMessage("Signing up...");
progressDialog.setCancelable(false);
progressDialog.show();
wantToCloseDialog = true;
}
} else {
Log.d("signedIn", "onAuthStateChanged:signed_in:" + user.getUid());
mDatabase.child("users").child(user.getUid()).child("name").setValue(user.getDisplayName());
mDatabase.child("users").child(user.getUid()).child("imageUID").setValue(user.getPhotoUrl());
mDatabase.child("users").child(user.getUid()).child("uniqueUserName").setValue(uniqueUserName.getText().toString());
mDatabase.child("users").child(user.getUid()).child("followers").setValue("00");
mDatabase.child("users").child(user.getUid()).child("following").setValue("00");
mDatabase.child("unique-usernames").child(ts).setValue(uniqueUserName.getText().toString());
Intent mainIntent = new Intent(SignUpActivity.this, SplashActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
progressDialog.setMessage("Signing up...");
progressDialog.setCancelable(false);
progressDialog.show();
wantToCloseDialog = true;
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Snackbar snackbar = Snackbar
.make(coordinatorLayout, databaseError.getMessage(), Snackbar.LENGTH_LONG);
snackbar.show();
wantToCloseDialog = false;
}
});
}
if(wantToCloseDialog)
dialog.dismiss();
//else dialog stays open. Make sure you have an obvious way to close the dialog especially if you set cancellable to false.
}
});
} else {
Log.d("signedIn", "onAuthStateChanged:signed_in:" + user.getUid());
mDatabase.child("users").child(user.getUid()).child("name").setValue(userName.getText().toString());
mDatabase.child("users").child(user.getUid()).child("uniqueUserName").setValue(uniqueUserName.getText().toString());
mDatabase.child("users").child(user.getUid()).child("followers").setValue("00");
mDatabase.child("users").child(user.getUid()).child("following").setValue("00");
mDatabase.child("unique-usernames").child(ts).setValue(uniqueUserName.getText().toString());
Intent mainIntent = new Intent(SignUpActivity.this, SplashActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
progressDialog.dismiss();
}
} else {
// User is signed out
Log.d("signedOut", "onAuthStateChanged:signed_out");
}
// ...
}
};
I have never seen any such error before and that's why I have no idea what's happening here.
Please let me know what is causing this error!
After looking deeply into code at least 10-12 times, I got the problem here.
The solution was to add .toString()
with user.getPhotoUrl()
in this line of code: mDatabase.child("users").child(user.getUid()).child("imageUID").setValue(user.getPhotoUrl());
This answer here gave me a bit hint. Thanks qbix.
So, it has been solved now!
这篇关于获取'E / AndroidRuntime:错误报告崩溃android.os.TransactionTooLargeException'点击AlertDialog的正面按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!