Android Question Showcustomtoast java.lang.RuntimeException

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Hi all,
This error is generated, in the model samsung s21 Android 11 SDK30, it does not happen on other phones, can someone guide me?


java.lang.RuntimeException:
at anywheresoftware.b4a.AbsObjectWrapper.getObject (AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.ViewWrapper.setBackground (ViewWrapper.java:105)
at com.intelliquestion.youspeak.chat_com._showcustomtoast (chat_com.java:4836)
at com.intelliquestion.youspeak.chat_com._rewad_rewarded (chat_com.java:4650)
at java.lang.reflect.Method.invoke (Native Method)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:213)
at anywheresoftware.b4a.keywords.Common$11.run (Common.java:1178)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8512)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)

Code:

B4X:
Sub rewad_Rewarded (Item As Object)  
    Dim cs As CSBuilder
     
    cs.Initialize.Alignment("ALIGN_CENTER").RelativeSize(30dip).Typeface(Typeface.SANS_SERIF).bold.Color(Colors.White).Size(18).Append(Starter.loc.Localize("Has sido recompensado, podrás enviar hasta ")).Pop.Pop
   
    cs.bold.Color(Colors.Red).Size(25).Append(contador_publicidad).Pop.Pop.Pop
    cs.Color(Colors.White).Size(18).Append( Starter.loc.Localize(" traducciones , recuerda que siempre tienes la opción de  ")).Pop
    cs.Color(Colors.White).Size(20).Append(Starter.loc.Localize("suscribirte")).Pop
    cs.Color(Colors.White).Size(18).Append( "  a  ").Append(CRLF). Pop
   
    cs.bold.Color(Colors.White).Size(27).Append("app").popall
   
    ShowCustomToast(cs, True, Colors.RGB(25,208,35))
   
   
End Sub



Sub ShowCustomToast(Text As Object, LongDuration As Boolean, BackgroundColor As Int)

   Dim ctxt As JavaObject
   ctxt.InitializeContext
   Dim duration As Int
   If LongDuration Then duration = 1 Else duration = 0
   Dim toast As JavaObject
   toast = toast.InitializeStatic("android.widget.Toast").RunMethod("makeText", Array(ctxt, Text, duration))
   Dim v As View = toast.RunMethod("getView", Null)
   Dim cd As ColorDrawable
   cd.Initialize(BackgroundColor, 20dip)
   v.Background = cd
   toast.RunMethod("show", Null)
End Sub

regards
 
Top