2012-02-09 199 views
0

我试图创建一个简单地启动网站的应用程序。我得到的代码显示没有错误,但当我运行它在Web测试的东西它的应用程序崩溃并显示此错误消息。 “应用程序web视图(进程com.webview)已意外停止,请重试。 任何帮助将apreciated。Webview意外停止问题

下面是我为我的类代码和我的清单。

package com.webview; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.Window; 
import android.webkit.WebChromeClient; 
import android.webkit.WebView; 

public class WebViewActivity extends Activity { 

WebView mWebView; 

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    final Activity mActivity = this; 
    super.onCreate(savedInstanceState); 

    // Adds Progrss bar Support 
    this.getWindow().requestFeature(Window.FEATURE_PROGRESS); 
    setContentView(R.layout.main); 


    // Makes Progress bar Visible 
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); 

    mWebView = (WebView) findViewById(R.id.webview); 
    mWebView.getSettings().setJavaScriptEnabled(true);  
    mWebView.loadUrl("http://google.com"); 


    mWebView.setWebChromeClient(new WebChromeClient() 
    { 
     public void onProgressChanged(WebView view, int progress) 
     { 
      //Make the bar disappear after URL is loaded, and changes string to Loading... 
      mActivity .setTitle("Loading..."); 
      mActivity .setProgress(progress * 100); //Make the bar disappear after URL is loaded 

     } 
    }); 
} 
} 

清单

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.webview" 
    android:versionCode="1" 
    android:versionName="1.0"> 
<uses-sdk android:minSdkVersion="10" /> 

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <activity android:name=".WebViewActivity" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

</application> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
/> 
</LinearLayout> 

</manifest> 

调试器示出了该下面

[2012-02-09 13点57分18秒 - 模拟器]未知savevm部类型95

[2012-02-09 13时57分52秒 - web视图] HOME可达设备 '模拟器-5554'

[2012-02-09 13时57分52秒 - web视图]上传web视图。 APK到设备 '模拟器-5554'

[2012-02-09十三点57分52秒 - web视图]安装WebView.apk ...

[2012-02-09 13时58分14秒 - web视图]成功!

[2012-02-09 13时58分14秒 - web视图]上设备模拟器-5554

[2012-02-09 13点58分15秒 - web视图]开始的活动com.webview.WebViewActivity ActivityManager:开始:意向{行动= android.intent.action.MAIN

猫= [android.intent.category.LAUNCHER] CMP = com.webview/.WebViewActivity}

+0

请从logcat发布错误&stacktrace。 – Pedantic 2012-02-09 19:53:52

+0

我使用Eclypse和新的这一切。我不知道你要求什么或如何找到它。 – CsharpBeginner 2012-02-09 19:56:15

+0

[2012-02-09 13:57:18 - Emulator] Unknown savevm section type 95 – CsharpBeginner 2012-02-09 19:57:33

回答

1

试试这个,我所做的就是移动将WebView声明为main.xml,并且该更改运行良好。

的Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.webview" 
    android:versionCode="1" 
    android:versionName="1.0"> 
    <uses-sdk android:minSdkVersion="10" /> 

    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".WebViewActivity" 
      android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    </application> 
</manifest> 

maix.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 

    <WebView 
     android:id="@+id/webview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
    /> 
</LinearLayout> 
+0

谢谢生病明天早晨测试一下,并接受您的答案。 Apreciate帮助。 – CsharpBeginner 2012-02-10 02:34:00

0

你必须把权限web视图清单中的 这上面的权限:

没有此权限,webview将无法运行