Hi,
I have a trouble with my app.
The app is fine when I run it in debug mode, but crash in release mode.
in debug mode all works fine
this is the log in debug mode
I attach the resumable subs that crash
and the function that call this function
this is a sub in main
Many many thanks to your help
marco
I have a trouble with my app.
The app is fine when I run it in debug mode, but crash in release mode.
release mode crash:
controllo_g$ResumableSub_Leggiscriviresume (java line: 145)
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1605)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116)
at java.net.SocketOutputStream.write(SocketOutputStream.java:161)
at anywheresoftware.b4a.objects.streams.File$OutputStreamWrapper.WriteBytes(File.java:534)
at ak.otto.controllo_g$ResumableSub_Leggiscrivi.resume(controllo_g.java:145)
at ak.otto.controllo_g._vvvvvvvvvvvvvvv5(controllo_g.java:107)
at ak.otto.main$ResumableSub_GestisciTag.resume(main.java:2019)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1770)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:7864)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
this is the log in debug mode
debug mode log:
----Resume----
Techs: [android.nfc.tech.NfcV, android.nfc.tech.Ndef]
E0040150EDE41BE3
collegato
leggiscivi: ?alfa?,TNLGFR75L29L885L,00631861200,180283
fineOut
Run
Run
Run
Run
Run
Run
Run
Run
Run
Run
Run
Run
Run
Run
avail 131
count 131
RISPOSTA N@Dipendente xxxxxxxxxx....xxxxxx
Run
function that crash:
public Sub Leggiscrivi(stringa As String)As ResumableSub
Dim o As OutputStream
Dim b() As Byte = stringa.GetBytes("UTF-8")
Log("leggiscivi: "&stringa)
o=sckt.OutputStream
o.WriteBytes(b,0,b.Length)
o.Flush
Log("fineOut")
Dim i As InputStream
i=sckt.InputStream
Dim buffer(1024) As Byte
Dim count As Int = 0
Dim length As Int = 0
Dim risposta As String
risposta="N"
'response loop (need exit condition)
Do Until count=-1
'Log("Do until "&count)
'you can also send here more
length = i.BytesAvailable '?
count = i.ReadBytes(buffer, 0, length)
Sleep(10)
If (length>0) Then
Dim risposta As String
Log("avail "&length)
Log("count "&count)
risposta=BytesToString(buffer,0,length,"UTF-8")
Log("RISPOSTA "&risposta)
count=-1
'Return risposta
' If risposta.StartsWith("S") Then
' Main.Smile.Bitmap=LoadBitmap(File.DirAssets,"spuntaverde.png")
' Main.Smile.invalidate
' Main.vedismile(True)
' Else
' Main.Smile.Visible=False
' Main.ora.Visible=True
' Main.ora.SingleLine=False
' Main.ora.Color=Colors.Red
' Main.ora.TextColor=Colors.White
' Main.ora.TextSize=12
' Main.ora.Text="NON PUO' ENTRARE "&Chr(10)&Chr(13)&risposta.SubString2(2,risposta.IndexOf("#"))
'End If
'refresh.Enabled=True
End If
Log("Run")
Loop
'N@Dipendente CF TNLGFR75L29L885L non abilitato per cantiere 210100#f.fabrizio@garcspa.it;servizio.sicurezza@garcspa.it?3703276759
Return risposta
End Sub
and the function that call this function
call to subs:
Sub GestisciTag
Dim crs As Cursor
Dim str As String
crs=Db.ExecQuery ("Select coalesce(ar.nome,"&""""""&")||"""&" "&"""||coalesce(ar.cognome,"&""""""&") As descr,coalesce(ar.codfisc,'')AS codfisc," _
&"coalesce(acf.ragsoc1,'')as dittaop,coalesce(acf.piva,'') AS piva from anaris ar inner join r_disp_ris rdr on rdr.idris=ar.id " _
&"inner join anadisp ad on ad.id=rdr.iddisp left JOIN anaclifor acf on ar.idditta_f=acf.id where ad.codice="""&uidp&"""")
If crs.RowCount>0 Then ' è un operatore
crs.Position=0
If parametri.controllo Then
controllo_g1.Initialize("xx.xx.xx.xx",yyyy) '(crs.GetString("codfisc"),crs.GetString("piva"),"180283")
wait for(controllo_g1.attendiInit) complete (result As Boolean)
If result Then
Log("collegato")
Dim message,risposta As String
message= "?alfa?,"&crs.GetString("codfisc")&","&crs.GetString("piva")&","&"180283"&Chr(10)&Chr(13)
wait for(controllo_g1.Leggiscrivi(message)) complete (risposta As String)
If risposta.StartsWith("S") Then
Smile.Bitmap=LoadBitmap(File.DirAssets,"spuntaverde.png")
Smile.invalidate
vedismile(True)
Else
Smile.Visible=False
ora.Visible=True
ora.SingleLine=False
ora.Color=Colors.Red
ora.TextColor=Colors.White
ora.TextSize=12
ora.Text="NON PUO' ENTRARE "&Chr(10)&Chr(13)&risposta.SubString2(2,risposta.IndexOf("#"))
End If
refresh.Enabled=True
End If
Many many thanks to your help
marco