gpt4 book ai didi

java - Android Webview 因错误而崩溃(错误 | EGL_BAD_DISPLAY)

转载 作者:行者123 更新时间:2023-11-30 10:49:34 24 4
gpt4 key购买 nike

我正在创建一个简单的 WebView 。我已成功从 Internet 加载网页,但在尝试从我的下载文件夹加载 HTML 文档时遇到问题。

我创建了一个 super 简单的 html 文档并将其放在下载文件夹中

我的 Activity 是通过单击 mainActivity 上触发 Intent 的按钮来加载的。

webview 像这样在 onCreate 中加载:

@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());
}

从日志中得到的路径是/storage/emulated/0/Download/index.html

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

仅供引用,HTML文件如下:

<!DOCTYPE html>

<html>
<head>

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

</body>
</html>

最佳答案

您似乎没有将 URL 传递给 loadUrl(),而是传递了路径。

添加 file:// 方案。

关于java - Android Webview 因错误而崩溃(错误 | EGL_BAD_DISPLAY),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35352357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com