androidappguru
Lurker
i need to write an app that gets parameters from a https get request
I am using the following code
[JAVA]
}
[/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
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. */
/** 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
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
String test= myhttp().toString();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView test1 =
}
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;
}
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