BaseTransientBottomBar和相关的错误,以及如何解决它 [英] BaseTransientBottomBar and related bug, and how to resolve it

查看:97
本文介绍了BaseTransientBottomBar和相关的错误,以及如何解决它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我尝试解决以下问题:

Firstly, What I tried to resolve the issue below:

步骤1.我在BaseActivity和BaseActivity抽象类中放置了一个方法,以了解何时停止Activity和何时破坏视图(片段的根视图)[在两种情况下都返回true,但在事件发生前返回false (称为onStop(),onViewDestroyed()).

Step 1. I have put a method in my BaseActivity and BaseActivity abstract class, to know when the Activity is stopped and when view (root view of fragment) is destroyed [returns true in both the cases, but false before the event (onStop(), onViewDestroyed()) is called].

第2步.当两者中的任何一个都返回true时,我阻止显示一个和唯一的SnackBar.还检查了BaseActivity的isFinishing().

Step 2. I have prevented the one and only SnackBar to be shown when the true is returned in any of the both. Also checked isFinishing() of the BaseActivity.

但是错误不会消失.

我想进一步了解此类:

android.support.design.widget.BaseTransientBottomBar

以及与此相关的内部异常,以及如何解决以下问题:

and the internal exception related to it, and how to resolve the following:

08-25 16:45:50.826 5618-5688/com.my_package D/CrashlyticsCore: Session 5B8139230285-0001-15F2-C62ED7C4B2D1 has fatal exception: true
08-25 16:45:50.827 5618-5688/com.my_package D/CrashlyticsCore: Session 5B8139230285-0001-15F2-C62ED7C4B2D1 has non-fatal exceptions: false
08-25 16:45:51.481 5618-5618/com.my_package E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.my_package, PID: 5618
    java.lang.IllegalStateException: ScrollView can host only one direct child
        at android.widget.ScrollView.addView(ScrollView.java:251)
        at android.support.design.widget.BaseTransientBottomBar.showView(BaseTransientBottomBar.java:428)
        at android.support.design.widget.BaseTransientBottomBar$1.handleMessage(BaseTransientBottomBar.java:176)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:168)
        at android.app.ActivityThread.main(ActivityThread.java:5845)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
08-25 16:45:53.654 5618-5688/com.my_package D/CrashlyticsCore: Removing report at /data/user/0/com.my_package/files/.Fabric/com.crashlytics.sdk.android.crashlytics-core/fatal-sessions/5B8139230285-0001-15F2-C62ED7C4B2D1.cls
08-25 16:45:58.626 9576-9643/com.my_package D/CrashlyticsCore: Session 5B813A670174-0002-15F2-C62ED7C4B2D1 has fatal exception: false
08-25 16:45:58.627 9576-9643/com.my_package D/CrashlyticsCore: Session 5B813A670174-0002-15F2-C62ED7C4B2D1 has non-fatal exceptions: false
    No events present for session ID 5B813A670174-0002-15F2-C62ED7C4B2D1
    Removing session part files for ID 5B813A670174-0002-15F2-C62ED7C4B2D1

详细信息:

请注意,我的是Desire 816 HTC设备,它是从奇巧开始的,现在已升级到MarshMallow,但仍然存在奇巧的错误,例如相机在拍摄第一张照片后没有释放资源并崩溃了.

Please note that mine is Desire 816 HTC device, it started from KitKat, and is now upgraded to MarshMallow, but still has the bugs of KitKat, like Camera not releasing resources and crashing, subsequently, after taking first picture.

但是必须有一些解决方案来防止这种情况发生,例如以下解决方案:

But there must be some solution to prevent this, like the following solution:

https://stackoverflow.com/a/52014209/787399

我最诚挚的问候.

推荐答案

我使用自己的答案解决了该问题:

I resolved it using my own answer:

当我在onDestroy()中使用布尔变量并进行检查时,我知道我不应该显示Snackbar,因为它使用view作为第二个参数.解释链接:

When I used a boolean variable in onDestroy(), and checked with it, I knew that I should not be showing Snackbar, as it uses view as a second parameter. The link for explanation:

片段onStop()与onDetach(),onDestroy()或onDestroyView()相同吗?

也由于以下链接中所述的限制:

also because of restrictions as nicely described in the following link:

https://developer.android.com/topic/libraries/architecture /lifecycle#kotlin

快乐编码:-)

这篇关于BaseTransientBottomBar和相关的错误,以及如何解决它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆