Loading data from internet (JSON)
in
Android Processing
•
1 year ago
Hi to all.
i've created a small app to explore twitter friendship.
it works well on desktop.
Loading it on a samsung Tab 10.1, it returns this error:
- android.os.NetworkOnMainThreadException
i've read some articles about it, understanding (in simple words) that newer version of android (3.0 +) won't allow networking in the main thread, to avoid to block the application during the loading.
it makes sense to me. but as i'm just sketching out some ideas and i won't bother to create a multithread superfine application, i'm wondering if there's a way to disable this feature.
i've found on stackoverflow
this solution (for java applications). it states to add these lines:
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- StrictMode.setThreadPolicy(policy);
as i don't really know how this sort of things work i tried to put it in the setup() function.
it loads without errors, but it don't solve the problem.
maybe isn't the right solution for processing.
any suggestion on how to solve the problem?
1