1

I'v got the following piece of code:

try {
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("http://www.flashstall.com/json.txt");
    HttpResponse httpResponse = httpClient.execute(httpPost);
} catch (Exception e) {
    Log.e("m40", "Error in http connection " + e.toString());
}

When I run it it logs "Error in http connection java.net.UnkownHostException: www.flashstall.com".

What am I doing wrong?

3 Answers 3

1

If I read your question correctly, you have a network error. The UnknownHostException is thrown when the hostname cannot be resolved. In your case its: www.flashstall.com.

Looks like you cannot access the site www.flashstall.com because perhaps you are not connected to the internet.

How to verify:

Open your adb shell $>adb shell and try to ping www.flashstall.com.

Sign up to request clarification or add additional context in comments.

Comments

0

From my understanding, you can't have json.txt as a part of the URI.

2 Comments

Why, is it because of the .txt extension?
json.txt is a file. Your webserver won't "understand" your call. Check what adrian wrote below =)
0

For a basic example convert your json.txt file into a php file and just echo your data. Then you'll be able to use it as:

HttpPost httpPost = new HttpPost("http://www.flashstall.com/json.php");

For a more detailed example check here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.