Astream Error in activity create

Emal

New Member
Licensed User
Longtime User
Hi

I have a problem with "AStream.Initialize"

I used some code from "Bluetooth Example" by @Erel for my app, and sometime when I try to connect Galaxy S to my device appers this msg

"An error has occurred in sub: module_activity_create (javaline: 237), java.lang.NullPointerException"

I find line 237 and the code is

Code: Copy
If AStream.IsInitialized = False Then
      AStream.Initialize(Main.serial1.InputStream, Main.serial1.OutputStream, "AStream")
   End If

Strange is that before update B4A to 1.92 this problem does not appeared,
maybe it's only an coincident.

Emanuel
 
re

Code: Copy
Sub Activity_Create(FirstTime As Boolean)
    Socket1.Initialize("Socket1")
    Socket1.Connect(Server_IP , Server_Port, Connection_Timeout)

you should init the AStream once socket connected
Code: Copy
Sub Socket1_Connected (Successful As Boolean)
    If Successful = False OR Socket1.Connected =False Then
      Socket1.Close
      Return
    Else
      AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
    End if
 
Upvote 0
Back
Top