Skip to content Skip to sidebar Skip to footer

Getting A Network Policy Violation When Running Network Operations In Another Class

I'm trying to use a simple HTTP get to load a string from a webpage. However, when I run the app in the emulator, I get a strict policy violation, and nothing is displayed. The pol

Solution 1:

You need to use a seperate Thread that executes the network activities. Android doesn't allow networking in the UI-thread since ICS and did raiss a force close after approx. 5 seconds before.

A good way to solve your task would be an AsyncTask that handles everying or a Thread with a listener for your Activity.

Check the Painless Threading Topic for more advice.

Post a Comment for "Getting A Network Policy Violation When Running Network Operations In Another Class"