I want to read these simple numbers which is a response from an HTTP API.
I have the response but I have no idea how do I convert it to string in my code.
below is the code I tried but failed.
try {
//Prepare Connection
myURL = new URL(url);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
//reading response
reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
while ((response = reader.readLine()) != null)
//print response
Toast.makeText(getApplicationContext(),response,Toast.LENGTH_SHORT).show();
//finally close connection
reader.close();
}
catch (IOException e){
e.printStackTrace();
Toast.makeText(getApplicationContext(), ""+e.toString(), Toast.LENGTH_SHORT).show();
}