【发布时间】:2012-02-09 19:49:50
【问题描述】:
我正在尝试创建一个简单地启动网站的应用程序。我得到的代码没有显示错误,但是当我在网络测试中运行它时,应用程序崩溃并显示此错误消息。 “应用程序 webView(进程 com.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 - Emulator] 未知的 savevm 部分类型 95
[2012-02-09 13:57:52 - WebView] HOME 在设备“emulator-5554”上启动
[2012-02-09 13:57:52 - WebView] 将 WebView.apk 上传到设备“emulator-5554”
[2012-02-09 13:57:52 - WebView] 安装 WebView.apk...
[2012-02-09 13:58:14 - WebView] 成功!
[2012-02-09 13:58:14 - WebView] 在设备模拟器 5554 上启动活动 com.webview.WebViewActivity
[2012-02-09 13:58:15 - WebView] ActivityManager:开始:Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] cmp=com.webview/.WebViewActivity }
【问题讨论】:
-
请从 logcat 发布错误和堆栈跟踪。
-
我正在使用 Eclypse 并且对这一切都是新手。我不知道您要什么或如何找到它。
-
[2012-02-09 13:57:18 - Emulator] 未知的 savevm 部分类型 95
-
您应该在 Eclipse 中有一个 DDMS 透视图,该透视图在停靠窗口中显示 logcat 输出。或者
click Window->Show View->Other...,展开Android组并从列表中选择LogCat。 -
好的,我找到了。但是当我在枚举器中运行应用程序时,LogCat 中没有任何内容
标签: android android-emulator android-webview