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. Camera Force Closed 9/10 of the times

ever since i upgraded to 1.5
my camera keep force close on me

Here is the logs from the device maybe someone can help me

06-22 14:11:28.106: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:28.269: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:28.898: INFO/ActivityManager(62): Starting activity:
Intent { action=android.intent.action.MAIN
categories={android.intent.category.LAUNCHER} flags=0x10200000
comp={com.android.camera/com.android.camera.Camera} }
06-22 14:11:28.997: INFO/ActivityManager(62): Start proc
com.android.camera for activity com.android.camera/.Camera: pid=879
uid=10016 gids={1006, 2001, 3003}
06-22 14:11:29.077: INFO/jdwp(879): received file descriptor 13 from ADB
06-22 14:11:29.228: INFO/WindowManager(62): Setting rotation to 1, animFlags=0
06-22 14:11:29.237: INFO/WindowManager(62): Config changed: {
scale=1.0 imsi=0/0 locale=en_US touch=3 key=2/1/2 nav=3 orien=2 }
06-22 14:11:29.237: WARN/WindowManager(62):
performLayoutAndPlaceSurfacesLocked called while in layout
06-22 14:11:29.257: WARN/WindowManager(62):
performLayoutAndPlaceSurfacesLocked called while in layout
06-22 14:11:29.627: DEBUG/StatusBar(62): updateResources
06-22 14:11:29.827: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:29.837: DEBUG/CameraService(37): Connect E from
ICameraClient 0x2acc8
06-22 14:11:29.837: DEBUG/CameraService(37): new client (0x2acc8)
attempting to connect - rejected
06-22 14:11:29.837: WARN/dalvikvm(879): threadid=15: thread exiting
with uncaught exception (group=0x4000fe70)
06-22 14:11:29.847: ERROR/AndroidRuntime(879): Uncaught handler:
thread Thread-8 exiting due to uncaught exception
06-22 14:11:29.847: ERROR/AndroidRuntime(879):
java.lang.RuntimeException: Out of memory
06-22 14:11:29.847: ERROR/AndroidRuntime(879):     at
android.hardware.Camera.native_setup(Native Method)
06-22 14:11:29.847: ERROR/AndroidRuntime(879):     at
android.hardware.Camera.<init>(Camera.java:82)
06-22 14:11:29.847: ERROR/AndroidRuntime(879):     at
android.hardware.Camera.open(Camera.java:64)
06-22 14:11:29.847: ERROR/AndroidRuntime(879):     at
com.android.camera.Camera$2.run(Camera.java:659)
06-22 14:11:29.847: ERROR/AndroidRuntime(879):     at
java.lang.Thread.run(Thread.java:1058)
06-22 14:11:29.877: DEBUG/LocationManager(879): Constructor: service =
android.location.ilocationmanager$stub$pr...@43468848
06-22 14:11:29.918: INFO/Process(62): Sending signal. PID: 879 SIG: 3
06-22 14:11:29.918: INFO/dalvikvm(879): threadid=7: reacting to signal 3
06-22 14:11:30.007: INFO/dalvikvm(879): Wrote stack trace to
'/data/anr/traces.txt'
06-22 14:11:30.017: DEBUG/SensorManager(879): found sensor: AK8976A
3-axis Accelerometer, handle=0
06-22 14:11:30.017: DEBUG/SensorManager(879): found sensor: AK8976A
3-axis Magnetic field sensor, handle=1
06-22 14:11:30.037: DEBUG/SensorManager(879): found sensor: AK8976A
Orientation sensor, handle=2
06-22 14:11:30.037: DEBUG/SensorManager(879): found sensor: AK8976A
Temperature sensor, handle=3
06-22 14:11:30.307: INFO/DumpStateReceiver(62): Added state dump to 1 crashes
06-22 14:11:31.619: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:31.788: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:32.157: DEBUG/dalvikvm(62): GC freed 1907 objects / 296928
bytes in 228ms
06-22 14:11:32.408: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:33.187: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:34.777: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:34.930: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:35.469: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:36.238: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:37.889: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:37.889: INFO/InetAddress(62): Unknown host
android.clients.google.com, throwing UnknownHostException
06-22 14:11:37.997: WARN/CheckinService(62): Request failed:
java.net.UnknownHostException: Host is unresolved:
android.clients.google.com:443
06-22 14:11:38.049: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:38.598: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:38.939: WARN/ActivityManager(62): Launch timeout has
expired, giving up wake lock!
06-22 14:11:39.308: WARN/ActivityManager(62): Activity idle timeout
for HistoryRecord{435bc608
{com.android.camera/com.android.camera.Camera}}
06-22 14:11:39.369: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:40.958: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:41.120: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:41.668: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:42.427: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:43.998: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:44.180: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:44.427: DEBUG/dalvikvm(234): GC freed 458 objects / 17312
bytes in 121ms
06-22 14:11:44.770: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:45.551: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:47.108: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:47.278: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:47.828: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:48.598: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:49.477: DEBUG/dalvikvm(433): GC freed 791 objects / 29096
bytes in 162ms
06-22 14:11:50.224: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:50.387: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:50.938: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:51.718: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:53.269: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:53.448: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:53.988: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:54.781: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:56.340: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:56.523: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:11:57.058: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:11:57.832: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:11:59.388: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:11:59.579: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:12:00.143: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:12:00.910: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:12:02.459: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:12:02.653: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:12:03.205: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:12:03.967: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:12:05.517: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:12:05.527: INFO/Process(879): Sending signal. PID: 879 SIG: 9
06-22 14:12:05.547: INFO/ActivityManager(62): Process
com.android.camera (pid 879) has died.
06-22 14:12:05.607: INFO/WindowManager(62): Setting rotation to 0, animFlags=0
06-22 14:12:05.627: INFO/WindowManager(62): Config changed: {
scale=1.0 imsi=0/0 locale=en_US touch=3 key=2/1/2 nav=3 orien=1 }
06-22 14:12:05.637: INFO/WindowManager(62): Config changed: {
scale=1.0 imsi=0/0 locale=en_US touch=3 key=2/1/2 nav=3 orien=1 }
06-22 14:12:05.737: INFO/WindowManager(62): Config changed: {
scale=1.0 imsi=0/0 locale=en_US touch=3 key=2/1/2 nav=3 orien=1 }
06-22 14:12:05.777: DEBUG/StatusBar(62): updateResources
06-22 14:12:05.797: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:12:05.857: WARN/InputManagerService(62): Window already
focused, ignoring focus gain of:
com.android.internal.view.iinputmethodclient$stub$pr...@435f6f88
06-22 14:12:06.358: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000
06-22 14:12:07.138: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x260f78 user=000012c0, server=00000000
06-22 14:12:08.127: DEBUG/dalvikvm(62): GC freed 5039 objects / 303624
bytes in 232ms
06-22 14:12:08.788: WARN/AudioTrack(37): obtainBuffer timed out (is
the CPU pegged?) 0x271d8 user=000012c0, server=00000000
06-22 14:12:08.818: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3301c8 user=000012c0, server=00000000
06-22 14:12:08.971: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x3128d8 user=000012c0, server=00000000
06-22 14:12:09.497: WARN/AudioTrack(62): obtainBuffer timed out (is
the CPU pegged?) 0x1fe6c0 user=000012c0, server=00000000



Thanks
Rotem Or

--~--~---------~--~----~------------~-------~--~----~

2. Assets not appearing in emulator/G1

Hi there, I written have a fairly simple andoid app but it has one
major bug that's killing me! The app has a screen which saves
configuration options to two text files (I know there are built in
configuration classes but these don't have the scope that I require)
which reside in my project's assets folder. I can access these by
typing something like:

openFileInput("option02.txt");

This works fine in my emulator, the files appear under data/data/
<appname>/files and it all works great. However if I install the app
on my g1, these files never get inserted into that folder and my app
crashes as it can't find the files. I'm working on this with another
guy over svn - when he downloaded the code the files didn't transfer
into his emulator either even though they appear in his assets folder!
It's maddening..

Any ideas or suggestions much appreciated


Thanks

Stephen

--~--~---------~--~----~------------~-------~--~----~

3. packaging android-specific application to reusable jar file

4. horizontal/vertical finger swipe...

5. Is learning Java directly on the Android possible or a good idea?

6. window.opener' [null] is not an object

7. A2DP ills