iZettle / android-html2bitmap

Generates a bitmap from html by rendering the content inside an off screen webview
MIT License
56 stars 20 forks source link

Am I doin something wrong? #27

Closed MatthewHallberg closed 5 years ago

MatthewHallberg commented 5 years ago
    try {
        URL url = new URL(unityURL);
        Html2Bitmap html2Bitmap = new Html2Bitmap.Builder(UnityPlayer.currentActivity.getApplicationContext(),
                WebViewContent.url(url))
                .setTimeout(5)
                .build();

        Bitmap bitmap = html2Bitmap.getBitmap();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        bitmap.compress(CompressFormat.JPEG, 90, outputStream);
        try {
            UnityPlayer.UnitySendMessage("WebController", "OnWebImageReceived",outputStream.toString("UTF-8"));
        } catch (UnsupportedEncodingException i){
            Log.e("yo", "Unsupported encoding: " + i);
        }
    } catch (MalformedURLException e) {
        Log.e("yo", "MALFORMED URL: " + e);
    }

I am passing in a url and getting a timeout exception every time, is this normal, or am I doing something wrong?

MarijanGazica commented 5 years ago

Are you loading local or remote content? In case of loading remote, have you tried with timeout longer than 5 seconds? Also, have you tried just displaying the content in a good old fashioned WebView to see how long does it take and if it manages to load?

MarijanGazica commented 5 years ago

Closing due to inactivity