Error when playing with java

Not only python error memorandum but also java memorandum

Note

String settings </ b> Use "" to set the value to String type and'' to set the value to char type.

Error collection

java.lang.IllegalStateException: closed Error message </ b>

example.java


example E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: example, PID: XXXXX
    java.lang.IllegalStateException: closed
        at okio.RealBufferedSource.select(RealBufferedSource.kt:83)
        at okhttp3.internal.Util.readBomAsCharset(Util.kt:254)
        at okhttp3.ResponseBody.string(ResponseBody.kt:171)
        at example.AsyncHttp$1.onResponse(AsyncHttp.java:107)
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)

Situation & Cause </ b> I read the text on the server using okhttp (GET) and took out the contents with response.body (). String () and tried to do this and that. According to here , response.body (). String () can only be called once </ b>. And that. This time, it was called twice, once for log output and once for variable storage. Punch line </ b> When I commented out the log output, it worked fine. It seems good to store Response in a variable.

Cannot resolve symbol 'REQUEST_ENABLE_BLUETOOTH' Situation & Solution </ b> Occurs when checking the Bluetooth function of Android According to the referenced page, it should be initialized.

example.java


int REQUEST_ENABLE_BLUETOOTH = 0;//Like this

reference: https://stackoverflow.com/questions/50948225/cannot-resolve-symbol-request-enable-bluetooth

Recommended Posts