loadStrings from url not working in Android?

Hi guys! So I’m developing a small app in Android, and one activity Is made in processing. I thought that going from processing to android is easy, but I got some problems, maily that I can’t use the loadStrings function. Here is the exception:

09-14 08:17:57.022 22156-22156/processing.test.skbun E/AndroidRuntime: FATAL EXCEPTION: main
    Process: processing.test.skbun, PID: 22156
    android.os.NetworkOnMainThreadException
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:117)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:105)
        at java.net.InetAddress.getAllByName(InetAddress.java:1154)
        at com.android.okhttp.Dns$1.lookup(Dns.java:39)
        at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175)
        at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141)
        at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:26)
        at processing.core.PApplet.createInputRaw(PApplet.java:4977)
        at processing.core.PApplet.createInput(PApplet.java:4931)
        at processing.core.PApplet.loadStrings(PApplet.java:5236)
        at processing.test.skbun.skBun.settings(skBun.java:59)
        at processing.core.PApplet.handleSettings(PApplet.java:796)
        at processing.core.PApplet.initSurface(PApplet.java:475)
        at processing.android.PFragment.onCreateView(PFragment.java:147)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2343)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
        at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3221)
        at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3171)
        at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:192)
        at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
        at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
        at android.app.Activity.performStart(Activity.java:7157)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2937)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I tried using

seed = loadStrings("https://pastebin.com/raw/VWZk096D");

The pastern file is just a test file! I read some threads but nothing really helped me…

Did you enable internet permissions?

Kf

@marcg====

android >9 does not allow networking on the main thread;
https://developer.android.com/reference/android/os/NetworkOnMainThreadException
in order to solve that you have to use AsyncTask (for short networking operations) or create another thread ( for long operations) or change the strictModePolicy by code, which is not recommanded but possible.

@akenaton Yea I read some posts on other forums, but I’m fairly new to android so I wasn’t really able to make a new AsyncTask or a new thread inside the sketch java file. I disabled those restrictions, but just until I can find a better solution. If anyone would help me make a new thread or that asynctask thing :)) I’d be really gratefull

@kfrajer yes I did

actually, never mind this, because the network issues are fixed. I’ll make a new thread for another loadStrings problem.