i'm try to get json file from mvc 4 application using webapi
but i get an error in asynctask doinbackground method
java.lang.illegalargumentexception host may not be null
when i track my code i found that it crash on jsonparser in getjson from url at the last line of this code
public JSONObject getJSONFromUrl(String Url) throws JSONException
{
try {
Log.d("tony","6"+Url);
DefaultHttpClient httpClient = new DefaultHttpClient(); // to connect to http
Log.d("tony","7"+Url);
HttpGet httpGet=new HttpGet(Url);
Log.d("tony","8"+httpGet.getMethod());
HttpResponse httpResponse = httpClient.execute(httpGet);
and this is my do in background code
public JSONObject doInBackground(String... urls) {
// get url pointing to entry point of API
String address = urls[0].toString();
if (method.equals(LOAD_REQUEST))
{
return getJSON(address);
}
else
return makeHttpRequest(address, method, parameters);
}
the get json method
public JSONObject getJSON(String url){
JSONObject j = null;
try {
j=parser.getJSONFromUrl(url);
} catch (JSONException e) {
e.printStackTrace();
}
return j;
}