what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Rocky » Wed, 18 May 2011 17:58:47 GMT


Sponsored Links
 Hi my code (red colored) is not responding, saying that time out,
please let me know where i'm doing wrong.

// Prepare a request object
        HttpGet httpget = new HttpGet(" http://10.91.28.203 ");

        // Execute the request
        HttpResponse response = null;

        JSONObject json = new JSONObject();
        System.out.println("result = " + result);
        System.out.println("json object " + json.toString());

        try {
            System.out.println("inside try 1");
            response = httpclient.execute(httpget);

-- 
Thanks & Regards

Rakesh Kumar Jha

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by neha jain » Wed, 18 May 2011 18:33:20 GMT


 Whereas i know with GET request data is send as part of url and JSONObject
is used with POST.





-- 


Sponsored Links


Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Kostya Vasilyev » Wed, 18 May 2011 18:36:15 GMT


 Possibly a real connection error?

The 10.* range is for private subnets, if the server is on your 
company's internal network, then it won't be visible through the phone's 
mobile data connection (as that would be coming from the outside).


-- Kostya

18.05.2011 14:33, neha jain ?????:
Whereas i know with GET request data is send as part of url and JSONObject is used with POST. On Wed, May 18, 2011 at 10:58 AM, Rocky <rkjhaw1...@gmail.com Hi my code (red colored) is not responding, saying that time out, please let me know where i'm doing wrong. // Prepare a request object HttpGet httpget = new HttpGet(" http://10.91.28.203 "); // Execute the request HttpResponse response = null; JSONObject json = new JSONObject(); System.out.println("result = " + result); System.out.println("json object " + json.toString()); try { System.out.println("inside try 1"); response = httpclient.execute(httpget); -- Thanks & Regards Rakesh Kumar Jha -- --
-- Kostya Vasilyev -- http://kmansoft.wordpress.com --



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by neha jain » Wed, 18 May 2011 18:38:57 GMT


 Add this line and try.
 HttpConnectionParams.setConnectionTimeout(client.getParams(), 5000);






-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Rocky » Wed, 18 May 2011 18:41:24 GMT


 thanks Kostya,

so how to test it, "localhost:2853" also not supported.
please let me know, my code is ok









-- 
Thanks & Regards

Rakesh Kumar Jha
Software Developer
Symphony Services Corp (India) Pvt Ltd
Bangalore
(O) +918030274295
(R) +919886336619

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Kostya Vasilyev » Wed, 18 May 2011 18:51:38 GMT


 Localhost refers to your device's or the emulator's internal network - 
and that's probably not where your server is running.


Do you have INTERNET permission in the manifest?

If you do, two things to try:

- Open the URL with the device's web browser (or the emulator's);

- Use 'adb shell' and then 'ping' to check if the host is reachable.

-- Kostya

18.05.2011 14:41, Rocky :
thanks Kostya, so how to test it, "localhost:2853" also not supported. please let me know, my code is ok
-- Kostya Vasilyev -- http://kmansoft.wordpress.com --



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Rocky » Wed, 18 May 2011 18:55:45 GMT


 Hi Kostya,

INTERNET permission is there,

i'm pinging host, but not reachable,
what to do








-- 
Thanks & Regards

Rakesh Kumar Jha
Software Developer
Symphony Services Corp (India) Pvt Ltd
Bangalore
(O) +918030274295
(R) +919886336619

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Rocky » Wed, 18 May 2011 18:59:10 GMT


 10.91.28.203 its not reachable , but localhost is reachable, while
www.google.com is also not reachable from adb shell








-- 
Thanks & Regards

Rakesh Kumar Jha
Software Developer
Symphony Services Corp (India) Pvt Ltd
Bangalore
(O) +918030274295
(R) +919886336619

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Kostya Vasilyev » Wed, 18 May 2011 19:08:02 GMT


 18.05.2011 14:58, Rocky :
10.91.28.203 its not reachable , but localhost is reachable, while www.google.com < http://www.google.com > is also not reachable from adb shell
Then your device is not configured to access the Internet. -- Kostya Vasilyev -- http://kmansoft.wordpress.com --



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Diogo Salaberri » Wed, 18 May 2011 20:24:23 GMT


 // Create a default client HTTP
DefaultHttpClient cliente = new DefaultHttpClient();

// Set post or get method and set the URL
HttpPost post = new HttpPost("URL");

// Here you can set a parameter,
post.addHeader("Name", "Value");

// When you receive a response, you need to get this in a TRY/CATCH
try{
response = cliente.execute(post);
        HttpEntity entity = response.getEntity();
Out = EntityUtils.toString(entity);
}catch (Exception e) {
        // Do something with your exception
}

One more thing, if want to receive a JSON object, just use ( object =
(JSONObject) new JSONTokener(Out).nextValue(); ).. Cutting extra caracters
that isn't a JSON.

I hope can you enjoy this.. see you.

-- 
Atenciosamente;
Diogo Bonoto Salaberri
Bacharel em Cincia da Computao - UFPel

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Rocky » Wed, 18 May 2011 20:28:16 GMT


 Hi
I'm not getting any response from below line.

response = cliente.execute(post);







-- 
Thanks & Regards

Rakesh Kumar Jha
Software Developer
Symphony Services Corp (India) Pvt Ltd
Bangalore
(O) +918030274295
(R) +919886336619

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Diogo Salaberri » Wed, 18 May 2011 21:55:01 GMT


 verify your URL, are you requesting a local server our something like this ?








-- 
Atenciosamente;
Diogo Bonoto Salaberri
Bacharel em Cincia da Computao - UFPel

-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Vishal » Thu, 19 May 2011 02:50:47 GMT


 Little modification

HttpGet httpget = new HttpGet(" http://10.91.28.203 ");

    // Execute the request
     HttpResponse response = null;

     try {
       System.out.println("inside try 1");
       response = httpclient.execute(httpget);

         HttpEntity entity = response.getEntity();

         if(entity!=null)
         {
             BufferedReader reader = new BufferedReader(new
InputStreamReader(response.getEntity().getContent(), "UTF-8"));
            StringBuilder builder = new StringBuilder();
            for (String line = null; (line = reader.readLine()) !=
null;)
            {
                   builder.append(line).append("\n");
            }
           JSONTokener tokener = new JSONTokener(builder.toString());
           JSONArray finalResult = new JSONArray(tokener);

         }







-- 



Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Denis Shalagin » Thu, 19 May 2011 02:51:05 GMT


 Are you sure that ping for " http://10.91.28.203 " is OK?





-- 



Re: Re: what will be the parameter of HttpGet httpget = new HttpGet("http://10.91.28.203");

by Diogo Salaberri » Thu, 19 May 2011 03:50:15 GMT


 Your code is right, but can generate erros because, normally, the response
of a request have caracteres that can't be used like a native JSON. The
response string need to be looked more carefully, use subString is a hint.

bye

-- 
Atenciosamente;
Diogo Bonoto Salaberri
Bacharel em Cincia da Computao - UFPel

-- 



Other Threads

1. Starting a service from top-level launcher

Hi,

I am trying to make a 'headless' (i.e. UI-less) application. Is it possible
to start a service in my application from the top-level launcher (the one
accessed from the Android home screen) directly, that is, without the
launcher starting an activity which then start the service?

Simply adding the ACTION_MAIN and CATEGORY_LAUNCHER filters to the
declaration of the service in the manifest file does not work for me.

Thanks in advance,
Anders Feder

-- 

2. Very specific question about Foreground / Background tasks...



It will.


Nothing in Android is immune "from Android deciding to kill it".

http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 1.0 Available!

-- 

3. Could not open Selected VM debug port (8700). [error]

4. Problem with Ubuntu 9.10? Please read!

5. Very specific question about Foreground / Background tasks...

6. How to add View on a Map at specific Geopoint?

7. can't start application in the emulator