1. Download our Official Android App: Forums for Android!

Apps https cannot get request

Discussion in 'Android Development' started by androidappguru, Jun 10, 2011.

  1. androidappguru

    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Jun 10, 2011

    Jun 10, 2011
    1
    0
    5
    i need to write an app that gets parameters from a https get request
    I am using the following code
    [JAVA]

    package​
    org.example.encrypt;

     

    import​
    android.app.Activity;

    import​
    android.text.*;

    import​
    android.os.Bundle;

    import​
    javax.crypto.*;

    import​
    java.net.*;

    import​
    java.io.*;

    import​
    org.apache.http.client.HttpClient;

    import​
    org.apache.http.client.methods.*;

    import​
    org.json.*;

    import​
    org.apache.http.message.BasicNameValuePair;

    import​
    org.apache.http.params.HttpParams;

    import​
    org.apache.http.NameValuePair;


     

    import​
    java.io.IOException;

    import​
    java.io.InputStream;

    import​
    java.io.InputStreamReader;

    import​
    java.io.Reader;

    import​
    java.util.List;



    import​
    org.apache.http.HttpEntity;

    import​
    org.apache.http.HttpResponse;

    import​
    org.apache.http.HttpStatus;

    import​
    org.apache.http.client.methods.HttpGet;

    import​
    android.view.*;

    import​
    android.widget.TextView;

     
     
     
     
     
     
     

    public​
    class encrypt extends Activity {

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.
    main);

    try {
    String test= myhttp().toString();
    }
    catch (Exception e) {
    // TODO Auto-generated catch block

    e.printStackTrace();
    }

    TextView test1 = ​
    null;
    test1.setText(myhttp().toString());
    setTitle(R.string.
    test);



    }


    public String myhttp()throws Exception{
    URL kaupu=
    new URL("https://...");

    URLConnection k=kaupu.openConnection();
    BufferedReader in=
    new BufferedReader(new InputStreamReader(k.getInputStream()));
    String inputLine;

    while((inputLine=in.readLine())!=null)
    System.
    out.println(inputLine);



    in.close();

    return inputLine;

    }

    }









    [/JAVA]

    I want to be able to make an HTTPS get reuest with parameter to a URL then retrieve the response that will be a JSON string and parse the string to a json object. Can you please help
     

    Advertisement

  2. satellitemundo

    Rank:
    None
    Points:
    15
    Posts:
    29
    Joined:
    Aug 18, 2010

    Aug 18, 2010
    29
    0
    15

Share This Page

Loading...