B4A Library Serial: error occurred java.lang.NullPointerException

uskomp

Member
Licensed User
Hello
B4A version 4.0
No problem with smartphones HTC Desire HD (Android 2.3.5) and Sony Xperia Z1 (Android 4.4.4).
I have a problem with Samsung Galaxy XCover2 (GT-S7710, Android 4.1.2).


Source code:
Sub Serial1_Connected (Success As Boolean)
If Success Then
Dim os1 As OutputStream
os1=Serial1.OutputStream 'an error has occurred in sub: java.lang.NullPointerException Continue?
os1.WriteBytes(mybufx, 0, mybufx.Length)
os1.Flush
Serial1.Disconnect
BTAdm.Disable
Else
BTAdm.Disable :MsgBox("Error BT","")
End If
End Sub

Serial1.Initialize("Serial1") in sub Activity_Create

If Continue "Yes" then it prints OK.
Why is information about error always?
Any solution?

Thanks for answer
 

uskomp

Member
Licensed User
Hi
Problem has solved - I made pause 3 seconds for Bluetooth on, without pause is OK

BTAdm.Enable
'Pauza(3000)
If BTAdm.IsEnabled Then
If Serial1.IsEnabled Then :Serial1_Connected(True)
Else :Serial1.Connect3(BTAdr, MyPort)
End If
Else :BTAdm.Enable
End If

thanks
 
Top