How to show list object page in Android?












-1















I have trouble in my listing program. How to show list object data on web in Android? this is my code:



public void loadData() {
String data = txtSeach.getText().toString();
textView = (TextView) findViewById(R.id.mytextView);
String result = "";
// the year data to send
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("search", data));
InputStream is = null;
// http post
try {
URL url = new URL("http://www.grouprecipes.com/search");
URLConnection connection = url.openConnection();
connection.connect();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.grouprecipes.com/"
+ data + "/");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// convert response to string
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();

result = sb.toString();
textView.append(result);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}

// parse json data
try {
JSONArray jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++) {
// JSONObject json_data = jArray.getJSONObject(i);
JSONObject jsonObject = new JSONObject(result);
// textView.setTag(json_data);
// textView.getContext();

/*
* Log.i("log_tag","id: "+json_data.getInt("id")+
* ", name: "+json_data.getString("name")+
* ", sex: "+json_data.getInt("sex")+
* ", birthyear: "+json_data.getInt("birthyear")
*
* );
*/
}

} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());

}
}









share|improve this question




















  • 2





    What kind of error are you getting?

    – Peter Knego
    Nov 28 '10 at 9:43











  • Asked 4 years ago!

    – Nayan
    Aug 31 '15 at 6:30
















-1















I have trouble in my listing program. How to show list object data on web in Android? this is my code:



public void loadData() {
String data = txtSeach.getText().toString();
textView = (TextView) findViewById(R.id.mytextView);
String result = "";
// the year data to send
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("search", data));
InputStream is = null;
// http post
try {
URL url = new URL("http://www.grouprecipes.com/search");
URLConnection connection = url.openConnection();
connection.connect();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.grouprecipes.com/"
+ data + "/");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// convert response to string
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();

result = sb.toString();
textView.append(result);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}

// parse json data
try {
JSONArray jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++) {
// JSONObject json_data = jArray.getJSONObject(i);
JSONObject jsonObject = new JSONObject(result);
// textView.setTag(json_data);
// textView.getContext();

/*
* Log.i("log_tag","id: "+json_data.getInt("id")+
* ", name: "+json_data.getString("name")+
* ", sex: "+json_data.getInt("sex")+
* ", birthyear: "+json_data.getInt("birthyear")
*
* );
*/
}

} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());

}
}









share|improve this question




















  • 2





    What kind of error are you getting?

    – Peter Knego
    Nov 28 '10 at 9:43











  • Asked 4 years ago!

    – Nayan
    Aug 31 '15 at 6:30














-1












-1








-1








I have trouble in my listing program. How to show list object data on web in Android? this is my code:



public void loadData() {
String data = txtSeach.getText().toString();
textView = (TextView) findViewById(R.id.mytextView);
String result = "";
// the year data to send
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("search", data));
InputStream is = null;
// http post
try {
URL url = new URL("http://www.grouprecipes.com/search");
URLConnection connection = url.openConnection();
connection.connect();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.grouprecipes.com/"
+ data + "/");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// convert response to string
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();

result = sb.toString();
textView.append(result);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}

// parse json data
try {
JSONArray jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++) {
// JSONObject json_data = jArray.getJSONObject(i);
JSONObject jsonObject = new JSONObject(result);
// textView.setTag(json_data);
// textView.getContext();

/*
* Log.i("log_tag","id: "+json_data.getInt("id")+
* ", name: "+json_data.getString("name")+
* ", sex: "+json_data.getInt("sex")+
* ", birthyear: "+json_data.getInt("birthyear")
*
* );
*/
}

} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());

}
}









share|improve this question
















I have trouble in my listing program. How to show list object data on web in Android? this is my code:



public void loadData() {
String data = txtSeach.getText().toString();
textView = (TextView) findViewById(R.id.mytextView);
String result = "";
// the year data to send
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("search", data));
InputStream is = null;
// http post
try {
URL url = new URL("http://www.grouprecipes.com/search");
URLConnection connection = url.openConnection();
connection.connect();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.grouprecipes.com/"
+ data + "/");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// convert response to string
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();

result = sb.toString();
textView.append(result);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}

// parse json data
try {
JSONArray jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++) {
// JSONObject json_data = jArray.getJSONObject(i);
JSONObject jsonObject = new JSONObject(result);
// textView.setTag(json_data);
// textView.getContext();

/*
* Log.i("log_tag","id: "+json_data.getInt("id")+
* ", name: "+json_data.getString("name")+
* ", sex: "+json_data.getInt("sex")+
* ", birthyear: "+json_data.getInt("birthyear")
*
* );
*/
}

} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());

}
}






android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 17:05









Cœur

18.8k9110150




18.8k9110150










asked Nov 28 '10 at 8:46









laabroolaabroo

1




1








  • 2





    What kind of error are you getting?

    – Peter Knego
    Nov 28 '10 at 9:43











  • Asked 4 years ago!

    – Nayan
    Aug 31 '15 at 6:30














  • 2





    What kind of error are you getting?

    – Peter Knego
    Nov 28 '10 at 9:43











  • Asked 4 years ago!

    – Nayan
    Aug 31 '15 at 6:30








2




2





What kind of error are you getting?

– Peter Knego
Nov 28 '10 at 9:43





What kind of error are you getting?

– Peter Knego
Nov 28 '10 at 9:43













Asked 4 years ago!

– Nayan
Aug 31 '15 at 6:30





Asked 4 years ago!

– Nayan
Aug 31 '15 at 6:30












1 Answer
1






active

oldest

votes


















0














Your HTTP POST request to http://www.grouprecipes.com/ is returning HTML not JSON.






share|improve this answer
























  • yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

    – laabroo
    Nov 29 '10 at 7:39











  • HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

    – Peter Knego
    Nov 29 '10 at 8:32











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4296037%2fhow-to-show-list-object-page-in-android%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Your HTTP POST request to http://www.grouprecipes.com/ is returning HTML not JSON.






share|improve this answer
























  • yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

    – laabroo
    Nov 29 '10 at 7:39











  • HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

    – Peter Knego
    Nov 29 '10 at 8:32
















0














Your HTTP POST request to http://www.grouprecipes.com/ is returning HTML not JSON.






share|improve this answer
























  • yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

    – laabroo
    Nov 29 '10 at 7:39











  • HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

    – Peter Knego
    Nov 29 '10 at 8:32














0












0








0







Your HTTP POST request to http://www.grouprecipes.com/ is returning HTML not JSON.






share|improve this answer













Your HTTP POST request to http://www.grouprecipes.com/ is returning HTML not JSON.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '10 at 9:53









Peter KnegoPeter Knego

76.3k9115142




76.3k9115142













  • yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

    – laabroo
    Nov 29 '10 at 7:39











  • HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

    – Peter Knego
    Nov 29 '10 at 8:32



















  • yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

    – laabroo
    Nov 29 '10 at 7:39











  • HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

    – Peter Knego
    Nov 29 '10 at 8:32

















yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

– laabroo
Nov 29 '10 at 7:39





yes... how to make this a JSON and finished view in my apps use a list.. please help me... thanks

– laabroo
Nov 29 '10 at 7:39













HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

– Peter Knego
Nov 29 '10 at 8:32





HTML is not JSON and you can not easily make it JSON. Ask the site operator to provide this data as JSON.

– Peter Knego
Nov 29 '10 at 8:32




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4296037%2fhow-to-show-list-object-page-in-android%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory