i have created a jsonobject that pulls data from a server but it works only on android versions less than 3 (old ones). what will be the code to make it work on all the versions??
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DefaultHttpClient client;
client = new DefaultHttpClient();
HttpGet get = new HttpGet("http://saurabhgoyal.comoj.com/json_test.php");
HttpResponse r;
try {
r = client.execute(get);
HttpEntity e = r.getEntity();
InputStream is=e.getContent();
InputStreamReader isr=new InputStreamReader(is);
BufferedReader reader=new BufferedReader(isr);
String results=reader.readLine();
Toast.makeText(this, results, Toast.LENGTH_SHORT).show();
} catch (ClientProtocolException e1) {
// TODO Auto-generated catch block
Toast.makeText(this, "failure", Toast.LENGTH_SHORT).show();
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}