How can I fix unfortunately apps has been stopped?

enamul95

New member
Jan 4, 2014
1
0
0
Visit site
unfortunately apps has been stopped ?

Hello Sir,
I am new developer. I have used

public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

static InputStream iStream = null;
static JSONArray jarray = null;
//static String json = "";

// constructor
public JSONParser() {

}

// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {

// Making HTTP request
try {

// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();

}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}

// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}

// return JSON String
return jObj;

}




}

I am using AsyncTask.I just called it by
json = jsonParser.makeHttpRequest(url_login, "GET", params);
The problem is that when database or apache tomcate is not found then app has stopped giving message unfortunately app has been stopped
 

belodion

Co-Ambassador Team Lead
Moderator
Jun 10, 2014
39,362
245
63
Visit site
Re: unfortunately apps has been stopped ?

OP: Would you like this thread to be moved to the Android Developers forum, which I think would be a better place for it?

Posted via the Android Central App
 

Trending Posts

Forum statistics

Threads
942,379
Messages
6,913,759
Members
3,158,384
Latest member
FarajWala800