Hello everyone,
I would like to use OutputStream. I tested this code and it works in B4J but not in B4A.
Below is the inline Java code where I encountered the error message "Constructor not found":
but in B4A, I encountered the following log:
Log
Just to let you know, I have added the following line for the B4A version:
Could someone please take a look at it?
thank you
I would like to use OutputStream. I tested this code and it works in B4J but not in B4A.
Below is the inline Java code where I encountered the error message "Constructor not found":
B4X:
Dim out As JavaObject
out.InitializeNewInstance($"${Application.PackageName}.main$MyOutputStream"$, Array(Me))
#If Java
import java.io.*;
import anywheresoftware.b4a.B4AClass;
public static class MyOutputStream extends OutputStream {
B4AClass cls;
private boolean closed;
public MyOutputStream (B4AClass cls) {
this.cls = cls;
}
public void write(int b) throws IOException {
if (closed)
throw new IOException("closed");
cls.getBA().raiseEventFromDifferentThread (null, null, 0, "data_available", true, new Object[] {new byte[] {(byte)b}});
}
public void write(byte b[], int off, int len) throws IOException {
if (closed)
throw new IOException("closed");
byte[] bb = new byte[len];
System.arraycopy(b, off, bb, 0, len);
cls.getBA().raiseEventFromDifferentThread (null, null, 0, "data_available", true, new Object[] {bb});
}
public void close() {
closed = true;
}
}
#End if
but in B4A, I encountered the following log:
Log
B4X:
starter$ResumableSub_httpClient_ResponseSuccessresume (java line: 235)
java.lang.RuntimeException: Constructor not found.
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:95)
at com.example.exa.starter$ResumableSub_httpClient_ResponseSuccess.resume(starter.java:235)
at com.example.exa.starter._httpclient_responsesuccess(starter.java:205)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7884)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
starter$ResumableSub_httpClient_ResponseSuccessresume (java line: 235)
java.lang.RuntimeException: Constructor not found.
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:95)
at com.example.exa.starter$ResumableSub_httpClient_ResponseSuccess.resume(starter.java:235)
at com.example.exa.starter._httpclient_responsesuccess(starter.java:205)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7884)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Just to let you know, I have added the following line for the B4A version:
B4X:
import anywheresoftware.b4a.B4AClass;
Could someone please take a look at it?
thank you