The below code is not working.
String url = "http://my/url/username/pswd";
String result = "";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv;
tv = (TextView) findViewById(R.id.text1);
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
request.addHeader("apikey", "DeveloperWy7ayxR");
request.addHeader("Content-Type","application/json");
ResponseHandler handler = new BasicResponseHandler();
try {
result = httpclient.execute(request, handler);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();
Log.i("myLog", result);
tv.setText(result);
}
I tested url and headers with advanced rest client, it worked. Am I missed anything?