Android Question LastException.Message crash!

techknight

Well-Known Member
Licensed User
Longtime User
I keep getting this everytime the Asyncstreams_error sub is called:

java.lang.RuntimeException: Object should first be initialized (Exception).

My code is:

B4X:
Sub AStreams_Error
    ToastMessageShow("Dropped connection to server. Reason: " & LastException.Message, True)
    Astreams.Close
    Socket1.Close
    Connected = False
End Sub

The error is occuring on the Toastmessage line.

any ideas?
 

G-ShadoW

Active Member
Licensed User
Longtime User
B4X:
Sub AStreams_Error
Try
    ToastMessageShow("Dropped connection to server. Reason: " & LastException.Message, True)
    Astreams.Close
    Socket1.Close
    Connected = False
Catch
Log("Error: " & LastException.Message)
End Try
End Sub

maybe from log you will see what error was it...
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Error: java.lang.Exception: java.lang.RuntimeException: Object should first be initialized (Exception).
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
Something is not initialized... Sub Astrems Error is made for that, when something is wrong with astrems related code, I dont think that you will get any other help from other members with just posted code above.
Good luck
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Well the code works. That much I do know. But I changed servers and having a weird problem with the server, So i need to find out why my Socket is getting booted. So I decided to add the LastException, Boom crash.

I am thinking compiler problem.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
But that begs the question. Why isnt it initialized? BTW my Astreams is loaded/running in a service.
 
Upvote 0
Top