I tried to call the Toast from Fragment, on the Click of a Button. The Main Layout was MotionLayout if that helps.
On the button press, the toast is either delayed or never appears. Initially, I repeatedly pressed the button to trigger the Toast but the app crashed with the Exception stated below.
2020-08-19 18:47:29.961 6627-6627/ E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.omega.cart, PID: 6627
java.lang.IllegalStateException: View android.widget.RelativeLayout{6e6c3c3 V.E...... ......I. 0,0-0,0 #7f0a00b2 app:id/color_toast_view} has already been added to the window manager.
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:328)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
at android.widget.Toast$TN.handleShow(Toast.java:499)
at android.widget.Toast$TN$1.handleMessage(Toast.java:403)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I tried to call the Toast from Fragment, on the Click of a Button. The Main Layout was MotionLayout if that helps.
On the button press, the toast is either delayed or never appears. Initially, I repeatedly pressed the button to trigger the Toast but the app crashed with the Exception stated below.