单击 AlertDialog 的“肯定”按钮时获取“E/AndroidRuntime:错误报告崩溃 android.os.TransactionTooLargeException”

2024-03-20

我收到此错误:

E/AndroidRuntime: Error reporting crash android.os.TransactionTooLargeException

还有这个:

java.lang.StackOverflowError: stack size 8MB

运行下面给定的代码时:

    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");
                    }
                    // ...
                }
            };

我以前从未见过任何此类错误,这就是为什么我不知道这里发生了什么。

请告诉我是什么导致了这个错误!


在深入研究代码至少 10-12 次之后,我发现了问题所在。

解决方案是添加.toString() with user.getPhotoUrl()在这行代码中:mDatabase.child("users").child(user.getUid()).child("imageUID").setValue(user.getPhotoUrl());

这个答案here https://stackoverflow.com/a/38128667/6144372给了我一点提示。谢谢qbix https://stackoverflow.com/users/4815718/qbix.

所以,现在已经解决了!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

单击 AlertDialog 的“肯定”按钮时获取“E/AndroidRuntime:错误报告崩溃 android.os.TransactionTooLargeException” 的相关文章

  • 如何在 60 分钟后删除共享首选项

    我想存储登录数据 但希望在 60 分钟后删除该数据 执行此操作的正确方法是什么 在这 60 分钟内可以关闭 停止 打开应用程序 我不想使用内部数据库 这是我的访问代码SharedPreferences sharedpreferences g
  • Jetpack Compose:制作全屏(绝对定位)组件

    我怎样才能在全屏渲染树的深处制作一个可组合的 类似于Dialog可组合作品 例如 当用户单击图像时 它会显示该图像的全屏预览 而无需更改当前路线 我可以用 CSS 来做到这一点position absolute or position fi
  • AndEngine MenuScene - 无法单击按钮

    我有一个关于 android 和 andengine 的小问题 这是我的主菜单的源代码 AbstractScene is extending Scene public class MainMenuScene extends Abstract
  • 双屏 Android Studio 中不显示自动补全

    我刚刚从 Eclipse 切换到 Android Studio IntelliJ 我不明白自动补全是如何工作的 我尝试了 Control Space Control Shift Space 但没有相关建议 不在 Java 文件中 也不在布局
  • 数据库中的持久日期不等于检索日期

    我有一个具有 Date 属性的简单实体类 此属性对应于 MySQL 日期时间列 Entity public class Entity Column name start date Temporal TemporalType TIMESTAM
  • Joshua Bloch 的构建器设计模式有何改进?

    早在 2007 年 我就读过一篇关于 Joshua Blochs 所采用的 构建器模式 的文章 以及如何修改它以改善构造函数和 setter 的过度使用 特别是当对象具有大量属性 其中大部分属性是可选的 时 本文对此设计模式进行了简要总结
  • 如何将 JSON 数据从 Android 发送到 php url?

    我想将登录信息从我的应用程序发送到 php url 因为这我的应用程序将崩溃 任何人都可以帮助我解决这个问题 这是我的服务器登录方法 我想将数据发送到此登录方法 Method public method login Parameters 3
  • 以 HTML 格式发送电子邮件

    我想发送 HTML 格式的电子邮件 如下图所示 我怎样才能做到这一点 请帮我 提前致谢 String body new String table tr td br header td tr br br Get b Best Score b
  • 我们如何使用 thymeleaf 绑定对象列表的列表

    我有一个表单 用户可以在其中添加任意数量的内容表对象这也可以包含他想要的列对象 就像在 SQL 中构建表一样 我尝试了下面的代码 但没有任何效果 并且当我尝试绑定两个列表时 表单不再出现 控制器 ModelAttribute page pu
  • TextView.setMaxLines 不起作用?

    在我的应用程序中 我有一个屏幕 其中显示一些文本 然后显示一张照片 文本的长度是可变的 有时根本没有 有时很多 所以我想对其进行设置 以便文本永远不会占用超过几行 但可以滚动 为下面的图像留下足够的空间 我这部分的视图组件是以编程方式创建的
  • 了解应用程序在后台时何时收到 Firebase 消息

    我知道这个标题有同样的问题 但不幸的是它没有得到正确的回答 它被接受了 here https stackoverflow com questions 37711082 how to handle notification when app
  • XML 配置中的 screenName 不起作用

    我刚刚在我的应用程序中添加了对 Google Analytics 分析 的支持 但我无法
  • 调试android数据绑定?

    谁能告诉我如何调试或找到数据绑定生成的代码 从this https www youtube com watch v NBbeQMOcnZ0链接我发现它生成了所需的代码 我猜您正在寻找自动生成的绑定 java 文件 我也在寻找他们 最后我在这
  • 动态更改按钮上的图像视图

    在我的应用程序中 我有按钮和ImageView 当我按下按钮时我想改变ImageView 我的可绘制文件夹中有 5 张图像 按下按钮时 ImageView 根据按钮单击一张一张地更改图像 我想要它的解决方案 感谢任何可以提供帮助的人 维护一
  • 在数组列表中过滤 Filterable 不取消之前的过滤

    我看过过滤器方法文档 其中显示调用过滤器会取消所有先前未执行的过滤请求 并发布一个稍后将执行的新过滤请求 但我收到的实际回调有些不同 在我的实现中 它不会取消先前的过滤器请求并调用publishResults 最近一次搜索条件后的上一次搜索
  • 如何从DataSource.Factory获取数据

    我必须调用此方法才能获取所有人员 我根本无法修改这个方法 Query SELECT FROM PERSON TABLE ORDER BY NAME DESC abstract fun getElements DataSource Facto
  • 什么是 Java2D 处理程序线程?

    我创建了一个使用 Hibernate 的示例 java 应用程序 当我进行线程转储时 我观察到一个名为 Java2D Disposer 的奇怪线程 有人能告诉我该线程的功能吗 AWT 系统中的某些实体需要最终确定以释放资源 最突出的例子是j
  • 如何让 Firebase 与 Java 后端配合使用

    首先 如果这个问题过于抽象或不适合本网站 我想表示歉意 我真的不知道还能去哪里问 目前我已经在 iOS 和 Android 上开发了应用程序 他们将所有状态保存在 Firebase 中 因此所有内容都会立即保存到 Firebase 实时数据
  • 使用 DBCP 配置 Tomcat

    在闲置一段时间 几个小时 后 我们收到了 CommunicationsException 来自 DBCP 错误消息 在异常中 位于这个问题的末尾 但我没有看到任何配置文件中定义的 wait timeout 我们应该看哪里 在 tomcat
  • 关闭扫描仪是否会影响性能

    我正在解决一个竞争问题 在问题中 我正在使用扫描仪获取用户输入 这是 2 个代码段 一个关闭扫描器 一个不关闭扫描器 关闭扫描仪 import java util Scanner public class JImSelection publ

随机推荐