1
我正在创建一个简单的web视图。我已成功从互联网加载网页,但在尝试从我的下载文件夹加载HTML文档时遇到麻烦。Android Webview崩溃与错误(Bad | EGL_BAD_DISPLAY)
我创建了一个超级简单的HTML文档,并把它放在
我的活动是通过点击mainActivity一个按钮,触发意图加载的下载文件夹中。
web视图被加载在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>
哈!那简单?我无法相信。谢谢! – silversunhunter
所以我试图通过一个相对路径正确?网址必须是绝对的? – silversunhunter