在android中使用webview,想要从一个html页面转到另一个html页面但是发生错误

时间:2016-12-12 13:59:20

标签: android webview

我在我的android项目中使用webview。应用程序从我想要的页面开始,即file.html(如下面的Webview代码所示)。

但问题是当我点击“下一页!”时我的file.html中的按钮,它应该将我重定向到file1.html。但该应用程序停止说“文件必须已重命名,移动或删除”。文件(file.html)在浏览器上运行正常。它完全重定向到file1.html。我正在使用Android Studio。谁能告诉我我做了什么错误?

我的webview代码部分如下所示:

//Webview Code:
WebView myWebView;
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myWebView = (WebView)findViewById(R.id.webView1);
        myWebView.getSettings().setUseWideViewPort(true);
        myWebView.getSettings().setLoadWithOverviewMode(true);
        myWebView.getSettings().setBuiltInZoomControls(true);
        myWebView.loadUrl("file:///android_asset/file.html");
    }

file.html的代码(应用程序启动时打开的文件)如下所示:

<!--file.html Code-->
<html>
<head>
    <title>My App</title>
    <link rel="stylesheet" href="styles.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <div id="pagegradient">
        <a href="file1.html" class="button width-200px"><span>NEXT PAGE!</span></a>
    </div>
</body>
</html>

我的资产文件夹看起来像这样

---> assets ---> file1.html

            ---> file2.html

            ---> file.html

logcat窗口的堆栈跟踪:

12-25 18:06:19.643 20937-20937/com.example.mnm.papp D/OpenSSLLib: OpensslErr:Module:13(114:155); file:external/openssl/crypto/asn1/asn1_lib.c ;Line:142;Function:ASN1_get_object
12-25 18:06:28.846 20937-20937/com.example.mnm.papp D/ActivityThread: BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{7c75e64 com.example.mnm.papp}}
12-25 18:06:28.847 20937-20937/com.example.mnm.papp V/ActivityThread: Handling launch of ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}
12-25 18:06:29.121 20937-20937/com.example.mnm.papp V/ActivityThread: ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}: app=android.app.Application@239c34c9, appName=com.example.mnm.papp, pkg=com.example.mnm.papp, comp={com.example.mnm.papp/com.example.mnm.papp.MainActivity}, dir=/data/app/com.example.mnm.papp-1/base.apk
12-25 18:06:30.124 20937-20937/com.example.mnm.papp D/ActivityThread: hoder:android.app.IActivityManager$ContentProviderHolder@48446e1,provider,holder.Provider:android.content.ContentProviderProxy@2cf0ec06
12-25 18:06:29.925 20937-20937/com.example.mnm.papp I/LibraryLoader: Expected native library version number "",actual native library version number ""
12-25 18:06:29.928 20937-20937/com.example.mnm.papp I/chromium: [INFO:library_loader_hooks.cc(106)] Chromium logging enabled: level = 0, default verbosity = 0
12-25 18:06:29.942 20937-20937/com.example.mnm.papp I/BrowserStartupController: Initializing chromium process, renderers=0
12-25 18:06:29.998 20937-21126/com.example.mnm.papp W/AudioManagerAndroid: Requires BLUETOOTH permission
12-25 18:06:30.003 20937-20937/com.example.mnm.papp W/chromium: [WARNING:resource_bundle.cc(315)] locale_file_path.empty()
12-25 18:06:30.004 20937-20937/com.example.mnm.papp I/chromium: [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=43 off=46092 len=2953
12-25 18:06:30.006 20937-20937/com.example.mnm.papp I/chromium: [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.pak from, fd:44 off:228796 len:643667
12-25 18:06:30.028 20937-20937/com.example.mnm.papp E/[DRVB][EXT][UTIL]: disp_only_chk: DRVB CHECK DISP PROCESS DONE ! (0/0x5/0x6/0x4)
12-25 18:06:30.028 20937-20937/com.example.mnm.papp E/[DRVB][EXT][UTIL]: disp_only_chk: DRVB CHECK DISP PROCESS DONE ! (720/1280/1)
12-25 18:06:30.286 20937-20937/com.example.mnm.papp V/ActivityThread: Performing resume of ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}
12-25 18:06:30.123 20937-20937/com.example.mnm.papp V/SettingsInterface: invalidate [system]: current 37 != cached 0
12-25 18:06:30.139 20937-20937/com.example.mnm.papp D/PasswordDatabase: constructor password.db
12-25 18:06:30.171 20937-21132/com.example.mnm.papp W/chromium: [WARNING:proxy_service.cc(901)] PAC support disabled because there is no system implementation
12-25 18:06:30.185 20937-20937/com.example.mnm.papp W/chromium: [WARNING:data_reduction_proxy_settings.cc(403)] SPDY proxy OFF at startup
12-25 18:06:30.201 20937-21147/com.example.mnm.papp D/SQLiteDatabase: beginTransaction()
12-25 18:06:30.205 20937-21147/com.example.mnm.papp D/SQLiteDatabase: endTransaction()
12-25 18:06:30.535 20937-20937/com.example.mnm.papp D/ActivityThread: ACT-AM_ON_RESUME_CALLED ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}
12-25 18:06:30.535 20937-20937/com.example.mnm.papp V/ActivityThread: Resume ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}} started activity: false, hideForNow: false, finished: false
12-25 18:06:30.578 20937-20937/com.example.mnm.papp V/ActivityThread: Resuming ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}} with isForward=true
12-25 18:06:30.578 20937-20937/com.example.mnm.papp V/ActivityThread: Scheduling idle handler for ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}
12-25 18:06:30.579 20937-20937/com.example.mnm.papp D/ActivityThread: ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}
12-25 18:06:35.883 20937-20937/com.example.mnm.papp D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}
12-25 18:06:35.908 20937-20937/com.example.mnm.papp D/ActivityThread: ACT-PAUSE_ACTIVITY handled : 1 / android.os.BinderProxy@271f5493
12-25 18:06:35.911 20937-20937/com.example.mnm.papp W/MediaPlayer: mediaplayer went away with unhandled events
12-25 18:06:38.929 20937-20937/com.example.mnm.papp V/ActivityThread: Finishing stop of ActivityRecord{33fdd8cd token=android.os.BinderProxy@271f5493 {com.example.mnm.papp/com.example.mnm.papp.MainActivity}}: show=false win=com.android.internal.policy.impl.PhoneWindow@3363cd4a
12-25 18:06:38.931 20937-20937/com.example.mnm.papp D/ActivityThread: ACT-STOP_ACTIVITY_HIDE handled : 0 / android.os.BinderProxy@271f5493

这些堆栈跟踪中的红线是:

12-25 18:06:30.028 20937-20937/com.example.mnm.papp E/[DRVB][EXT][UTIL]: disp_only_chk: DRVB CHECK DISP PROCESS DONE ! (0/0x5/0x6/0x4)
12-25 18:06:30.028 20937-20937/com.example.mnm.papp E/[DRVB][EXT][UTIL]: disp_only_chk: DRVB CHECK DISP PROCESS DONE ! (720/1280/1)

0 个答案:

没有答案