in my app i am trying to get an xml file from an URL. the url to which trying get consists of a string. Following is part of my code
URL url = new URL("http://..................");
Log.e("Gallery URl",""+url);
getWebPageContents(url);
}
private void getWebPageContents(URL url)
{
try{
if(url != null)
Log.e("webpage",""+url);
{
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet();
try
{
HttpResponse rsp = client.execute(get);
String tmpstr = EntityUtils.toString(rsp.getEntity());
Log.e("UserData "+tmpstr);
UserManual.IMGDATA=tmpstr;
getUserRegisteredContents(tmpstr);
}
catch(Exception asd)
{
Log.e(asd.toString());
}
}
When i checked with log value in log cat it shows that it is getting in to the URL and then into the getWebPageContents(url)
in the getWebPageContents(URL url) it is getting into the first try block and not in the second try block
Where i am going wrong please help me.....
You are not setting the url you want to get anywhere so I believe
rsp.getEntity()
results in a NullPointerExceptionAlso HttpGet accepts a
URI
orString
so either you use it as:or change
to
You are not using the URL in your code:
I think this is what you want: