Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T02.04-Solution-ConnectingToTheInternet (permission not explicitly required) #41

Closed
fernando-almeida opened this issue Jan 13, 2017 · 1 comment

Comments

@fernando-almeida
Copy link

Simply adding to AndroidManifest.xml

seems to not be enough to be able to make a request.

The only way I got this to work was to add the following code prior to calling the getResponseFromHttpUrl method
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);

I didn't see this issue reported and this was the only way I got the request to return results, otherwise an error would be thrown.
android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
Please advise on the best way to proceed regarding this issue.

@JeremySilverTongue
Copy link
Contributor

This is actually the expected behavior for this exercise. The next exercise shows how to get the networking onto a background thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants