silversunhunter
silversunhunter

Reputation: 1269

Android Webview crashing with error (Bad | EGL_BAD_DISPLAY)

I am creating a simple webview. I have successfully loaded a webpage from the internet but am having trouble when trying to load an HTML doc from my downloads folder.

I created a super simple html doc and put it in the Download folder

My activity is loaded by clicking a button on mainActivity that triggers an intent.

The webview is loaded in the onCreate like so:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_presentation_view);

        WebView myWebView = (WebView) findViewById(R.id.webView);

        File webFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), "/index.html");
        Log.d("Path", webFile.toString());
        myWebView.loadUrl(webFile.toString());
    }

The path from the log is /storage/emulated/0/Download/index.html

The LogCat:

02-11 16:39:02.571 629-1369/? I/ActivityManager: START u0 {cmp=com.asi.mediakiosk/.PresentationView} from uid 10112 on display 0
02-11 16:39:02.573 629-1369/? V/WindowManager: addAppToken: AppWindowToken{1c540cc0 token=Token{814ee43 ActivityRecord{1bdc27f2 u0 com.asi.mediakiosk/.PresentationView t213}}} to stack=1 task=213 at 1
02-11 16:39:02.575 190-190/? I/AudioFlinger: AUDIO_OUTPUT_FLAG_FAST accepted: frameCount=11258 mFrameCount=512
02-11 16:39:02.596 32328-32328/com.asi.mediakiosk D/cr_Ime: [InputMethodManagerWrapper.java:27] Constructor
02-11 16:39:02.597 32328-32328/com.asi.mediakiosk D/cr_Ime: [ImeAdapter.java:241] attach
02-11 16:39:02.597 32328-32328/com.asi.mediakiosk W/art: Attempt to remove local handle scope entry from IRT, ignoring
02-11 16:39:02.600 32328-32328/com.asi.mediakiosk W/AwContents: onDetachedFromWindow called when already detached. Ignoring
02-11 16:39:02.601 32328-32328/com.asi.mediakiosk D/cr_Ime: [InputMethodManagerWrapper.java:56] isActive: false
02-11 16:39:02.601 32328-32328/com.asi.mediakiosk D/Path: /storage/emulated/0/Download/index.html
02-11 16:39:02.603 32328-32328/com.asi.mediakiosk D/cr_Ime: [ImeAdapter.java:241] attach
02-11 16:39:02.609 629-4286/? V/WindowManager: Adding window Window{218e2b9f u0 com.asi.mediakiosk/com.asi.mediakiosk.PresentationView} at 8 of 15 (after Window{348931ab u0 com.asi.mediakiosk/com.asi.mediakiosk.MainActivity})
02-11 16:39:02.662 32328-32328/com.asi.mediakiosk D/cr_Ime: [ImeAdapter.java:241] attach
02-11 16:39:02.673 629-654/? I/ActivityManager: Displayed com.asi.mediakiosk/.PresentationView: +97ms
02-11 16:39:02.674 32328-32328/com.asi.mediakiosk D/cr_Ime: [AdapterInputConnection.java:499] finishComposingText
02-11 16:39:02.674 32328-32328/com.asi.mediakiosk D/cr_Ime: [AdapterInputConnection.java:145] Constructor called with outAttrs: inputType=0xa1 imeOptions=0x12000000 privateImeOptions=null
                                                            actionLabel=null actionId=0
                                                            initialSelStart=0 initialSelEnd=0 initialCapsMode=0x0
                                                            hintText=null label=null
                                                            packageName=com.asi.mediakiosk fieldId=2131492970 fieldName=null
                                                            extras=null
02-11 16:39:02.676 27545-27545/? I/Keyboard.Facilitator: onFinishInput()
02-11 16:39:02.676 32328-32328/com.asi.mediakiosk W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 32328
02-11 16:39:02.705 32328-32362/com.asi.mediakiosk D/OpenGLRenderer: endAllStagingAnimators on 0x425b7080 (RippleDrawable) with handle 0x7e0659f0

Just for reference, the HTML file is as follows:

<!DOCTYPE html>

<html>
<head>

</head>
<body>
<h1>Please show up, Please show up!</h1>

</body>
</html>

Upvotes: 2

Views: 1472

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69218

It seems you are not passing a URL to loadUrl() but a path.

Add the file:// scheme.

Upvotes: 1

Related Questions