Problem in Http Get Method..pls tell me..

by ragavendran s » Wed, 02 Sep 2009 22:12:17 GMT


Sponsored Links
 can u tell me how to send the Url to the server using Http Get method...

Here i m trying to insert a name into the databse .If i execute the below

showing code  there it tells "Connection to  http:localhost refused "

 i think the error is is in the Http method ..Would u tel me pls how to
Correct
it....


With ragards,

Raghav.S



My Code:


package simpl.http1;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class simplhttp1 extends Activity {
    /** Called when the activity is first created. */


    Button enter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        enter=(Button)findViewById(R.id.enter1);


        enter.setOnClickListener(new OnClickListener(){

            public void onClick(View v)
            {

                openconn();


            }
        });



    }

   public void openconn()

   {

                 String str11="murugan";
               String feed_url="
http://localhost:8080/Serv1/servlet/Servlet1?st1="+str11;
              HttpClient client=new DefaultHttpClient();
              HttpGet siteRequest = new HttpGet(feed_url);
              try {
                HttpResponse httpResponse = client.execute(siteRequest);
                TextView t = (TextView) findViewById(R.id.myTextView);

                 t.setText("Ok");
            } catch (ClientProtocolException e) {

                TextView t = (TextView) findViewById(R.id.myTextView);
                t.setText(e.getMessage());
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                TextView t = (TextView) findViewById(R.id.myTextView);
                t.setText(e.getMessage());
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

   }



}

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



Problem in Http Get Method..pls tell me..

by Urs Grob » Wed, 02 Sep 2009 23:44:28 GMT


 localhost is the device itself, not your host where the emulator is running
on. If I remember correctly you would have to use 10.0.2.2 instead of
localhost.

-- Urs





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


Sponsored Links


Other Threads

1. Converting bitmap to grayscale

I would like to convert a Bitmap to a grayscale array of bytes (one
byte per pixel). At the same time I want to just crop at section from
the middle. Having looked though the various api's it is not clear to
me what the best way would be.

The best way I have found in se java is as below;

BufferedImage image = new BufferedImage(cropWidth, cropHeight,
BufferedImage.TYPE_BYTE_GRAY);
Graphics g = image.getGraphics();
g.drawImage(colorImage, cropOffsetX, cropOffsetY, null);
g.dispose();

Leaving me with a graysale image of the right section;

What is the equivalent method with android api's. I am guessing it is
along these lines....

                Bitmap bm = Bitmap.createBitmap(500, 500,
Bitmap.Config.ALPHA_8); // ALPHA_8?
                Canvas c = new Canvas(bm);
                Paint paint = new Paint(); // should something be set
here to get grayscale?
                c.drawBitmap(bm, 200, 200, paint);
                bm..getPixels(...); // I want byte/pixel not int/
pixel ??


However, I have two questions;

1) What is ALPHA_8? is that grayscale?

I have a feeling that the grayscale effect should be done via some
"saturation" on the paint object, right?

2) once I have the Bitmap in grayscale and the right size, what is the
best way to get that to a byte[] of pixels (one byte per pixel) ?

Thanks.



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

2. Camera preview zoom?

Currently the camera performs previews of the shot at 480x320 allowing
for real time processing.

Is it possible define what part of full 1536x2024 camera image is used
for the smaller preview image? Basically some kind of zoom?

I am trying to get a more detailed part of the image, without have to
do a full camera acquire and crop that.


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

3. Update View after OnTouch, does not work?!?

4. Cannot create AVD in window XP

5. How to solve "G1/HTC Magic not recognized by ADB under Windows"

6. Radio image on opensource build for dream

7. Run android x86 (eee_701) in qemu (non-installer)?