I am trying to read the HTML code from a URL into a string as part of an Android app. It all works perfectly when I use "https://www.google.com", but when I use the website I want to get data from, "https://bmorgan17.github.io/DCD/resources/data_raw.html" I get this error.
Error: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x5c959090: Failure in SSL library, usually a protocol error
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0x59282c38:0x00000000)
Here is my code:
public class RecipeActivity extends AppCompatActivity {
static String result;
static private class RetrieveData extends AsyncTask<String, Void, String> {
    @Override
    protected String doInBackground(String... urlStr){
        // do stuff on non-UI thread
        StringBuilder htmlCode = new StringBuilder();
        String LOG_TAG = "APP";
        try{
            URL url = new URL(urlStr[0]);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                htmlCode.append(inputLine);
            }
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            Log.wtf(LOG_TAG, "Error: " + e.getMessage());
            Log.wtf(LOG_TAG, "HTML CODE: " + htmlCode);
        }
        Log.wtf(LOG_TAG, "HTML CODE: " + htmlCode);
        return htmlCode.toString();
    }
    @Override
    protected void onPostExecute(String htmlCode){
        // do stuff on UI thread with the html
        super.onPostExecute(htmlCode);
        result = htmlCode;
    }
}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.activity_recipe);
    TextView out = findViewById(R.id.tvHttp);
    new RetrieveData().execute("https://bmorgan17.github.io/DCD/resources/data_raw.html");
    out.setText(result);
}
}
If anyone could help me it would be great!
Edit:
- Galaxy Nexus
- Android Version: 4.2.2
- Min API: 17
I use this as a test phone because it is much faster than the emulator. If I need to make an emulator for a newer phone please tell me.
