Android Question [solved] error android.view.WindowManager$BadTokenException

musaso

Active Member
Licensed User
Longtime User
I am using b4a v 9.80
with this library ToastMessageShow v2.10 - lonleystar
at the time of displaying the toast message I get an error
With Android v5 it works perfect, but with Android 9 I have this error.
sorry for the english (google translator).

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:806)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
at it.giuseppe.salvi.notification.core.ToastShow$ToastManager.display(ToastShow.java:1519)
at it.giuseppe.salvi.notification.core.ToastShow$ToastManager.handleMessage(ToastShow.java:1498)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6762)
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)
 

DonManfred

Expert
Licensed User
Longtime User
Where is the projectupload showing the problem?
 
Upvote 0

musaso

Active Member
Licensed User
Longtime User
Hello DonManfred

simple Public Sub



B4X:
Public Sub MostrarToast
    Dim fecha As String = $"Fecha : ${DateTime.Date(Main.FechaBD)& CRLF & "Hora : "} ${DateTime.Time(Main.FechaBD)}"$
    toast.Initialize("")
    toast.withGravity(toast.Gravity.TOAST_CENTER)
    toast.withTextColor(Colors.Blue)
    toast.withAnimation(toast.Animation.FLY)
    toast.withDuration(4000)
    toast.withOval(True)       
    toast.create(fecha)
    toast.Show                                                 
End Sub
 
Upvote 0
Top