Android Question Receive text using AsyncStreamsText (Error)

mmanso

Active Member
Licensed User
Longtime User
Hi all,

I'm trying to receive simple text content through a server socket running in Android. From the foruns, I've found that I should use the AsyncStreamsText class.

I'm trying to but when I compile my project I get this error:



B4A version: 6.80
Parsing code. (0.00s)
Compiling code. (0.03s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.07s)
Compiling debugger engine code. (3.35s)
Compiling generated Java code. Error
B4A line: 23
astreams.Write(Text.GetBytes(charset))
javac 1.8.0_45
src\b4a\example\asyncstreamstext.java:64: error: no suitable method found for NumberToString(byte[])
__ref._astreams._write(null,BA.NumberToString(_text.getBytes(__ref._charset)));
^
method BA.NumberToString(double) is not applicable
(argument mismatch; byte[] cannot be converted to double)
method BA.NumberToString(float) is not applicable
(argument mismatch; byte[] cannot be converted to float)
method BA.NumberToString(int) is not applicable
(argument mismatch; byte[] cannot be converted to int)
method BA.NumberToString(long) is not applicable
(argument mismatch; byte[] cannot be converted to long)
method BA.NumberToString(Number) is not applicable
(argument mismatch; byte[] cannot be converted to Number)



Any help?

Thanks.
 

eps

Expert
Licensed User
Longtime User
The issue is that you are encoding the String to a Data object and then sending the Data object to the AsyncStream which expects a String.

You should have some warnings about 'Object converted to String. This is probably a programming mistake'.

I guess you are attempting to ensure that the String is UTF8 encoded in order to send it to the AsyncStream? But what you're actually doing is changing the data type of the string in question and then Asyncstream throws it's toys out of the pram as it is being sent a data type it isn't expecting.

Have you tried just sending the String as is, without the conversion?
 
Upvote 0
Top