Android Question Error in relese mode, not in debug using UDP

iz1kbp

Member
Hi to all, sorry in advance for my poor english.
I'm new to b4a system and I' develop and application to drive, from android, a my vb6 application via UDP socket.
the problem is in these lines but I don know why....

I've decalred Dim UDPSocket1 As UDPSocket in process globals and in activity create:
--------------------------------------------------------
If FirstTime Then
UDPSocket1.Initialize("UDP", 7000, 128)
ToastMessageShow("Porta 7000 initializzata.",True)
End If
------------------------------------------------------

I've a button (some buttons...but they have the same function).When I push button 1 (b1_click), it send a symply message:
------------------------------------------------
Dim Packet As UDPPacket
Dim data() As Byte
data = "Micro1 OFF".GetBytes("ASCII")
Packet.Initialize(data, "192.168.0.13",7000) 'IP and Port can be changed
UDPSocket1.Send(Packet)
-----------------------------------------
In debug...seem to be fine. In release , on smartphone give my error

here the log
--------------------------------------------------------------------------
Logger connected to: samsung SM-J600FN
--------- beginning of crash
--------- beginning of main
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
accesso
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
accesso
accesso
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
accesso
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
accesso
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
anywheresoftware.b4a.B4AUncaughtException
at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:193)
at anywheresoftware.b4a.debug.Debug.wait(Debug.java:217)
at anywheresoftware.b4a.debug.Debug.StartFromShell(Debug.java:109)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at JHS.Switch.main.afterFirstLayout(main.java:96)
at JHS.Switch.main.access$000(main.java:17)
at JHS.Switch.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_b1_click (java line: 627)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b1_click(main.java:627)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
main_b1_click (java line: 655)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b1_click(main.java:655)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
main_b1_click (java line: 627)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b1_click(main.java:627)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_b1_click (java line: 627)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b1_click(main.java:627)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
main_b2_click (java line: 823)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b2_click(main.java:823)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
main_b1_click (java line: 655)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b1_click(main.java:655)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_b1_click (java line: 627)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:305)
at libcore.io.IoBridge.sendto(IoBridge.java:542)
at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:125)
at java.net.DatagramSocket.send(DatagramSocket.java:723)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Send(SocketWrapper.java:289)
at JHS.Switch.main._b1_click(main.java:627)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7339)
at android.widget.TextView.performClick(TextView.java:14226)
at android.view.View.performClickInternal(View.java:7305)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27787)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7081)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
android.os.NetworkOnMainThreadException
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **

-------------------------------------------------


Is there som one than can show my the way to solve this problem?

thank's in advanve to any!

Mario
 

iz1kbp

Member
Hi Erel,sorry for troubble.
I've rewrite all the code and now it works fine. I'm from Visual Basic 6 syntax and may be some mistake in code .
Thank's for the replay!
mario
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…