Now we need to hit the API with the data on a click of the button. To achieve this, we need the flowing helper functions:
- ByPostMethod: Accepts the URL as a String and returns the response as an InputStream. This function takes the server URL string that we created using the Flask framework and returns the response from the server as an input stream:
InputStream ByPostMethod(String ServerURL) { InputStream DataInputStream = null; try { URL url = new URL(ServerURL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setInstanceFollowRedirects(false); connection.setRequestMethod( ...