i need to find a way to request an url with an edit text and display the json of that url. i have tried to use this code :
// URL to get contacts JSON
private static String id = null;
private static String url = "http://api.ccapp.it/v1/student/" + id + "/schedule/11";
// JSON Node names
private static final String TAG_LESSON = "class";
private static final String TAG_ROOM = "room";
private static final String TAG_TEACHER = "teacher";
// contacts JSONArray
JSONArray contacts = null;
// Hashmap for ListView
ArrayList<HashMap<String, String>> contactList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.roosteralluz);
//number input
final EditText input = (EditText) findViewById(R.id.editText2);
//search button
Button btnSearch = (Button) findViewById(R.id.button34);
btnSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
id = input.getText().toString();
// Calling async task to get json
new GetContacts().execute();
}
});
But when i try that code it returns this error: org.json.JSONException: Value <html><head><title>Slim of type java.lang.String cannot be converted to JSONObject
It is able to parse a link if i change id (look at code) to my own id. but i need to find a user his own id with an edittext.