I have the following code verbatim in an iOS app in the URLConnection ContentReceived but trying to get this to work in Android
Dim mb As MemoryBlock = content
Var outputStream As BinaryStream = BinaryStream.Create(folPathQuestion, True)
outputStream.Write(mb)
When trying to test this in Android, I am getting the following errors
Type mismatch error. Expected class MemoryBlock, but got String
(this is on the “Dim mb As MemoryBlock = content” line)
Parameter “value” expects type String, but this is class MemoryBlock
(this is on the “outputStream.Write(mb)” line)
Do I need to handle a MemoryBlock differently on Android? When hovering over MemoryBlock in code in the iOS project, I see the tip “MemoryBlock.Constructor(bytes as Integer)”. And hovering over in the Android project I see the same but also “MemoryBlock.Constructor(data as String)”. So not sure if that’s something worth noting
There are currently small differences with MemoryBlock in Xojo Android compared to iOS. Do you have access to the Testers channel to test upcoming Xojo versions? Could make a difference in this case.
Here’s code tested in 2024r3.1:
Dim content As String = "Cool"
Dim mb As MemoryBlock
Dim s As String
#If TargetAndroid And XojoVersion < 2024.04
mb = New MemoryBlock(content)
s = mb.StringValue(0, content.Bytes)
#Else
mb = content
s = mb
#EndIf
Var outputStream As BinaryStream = BinaryStream.Create(SpecialFolder.Documents.Child("test.txt"), True)
outputStream.Write(s)
outputStream.Close