2012-02-09 4 views
0

Création d'une application qui lance simplement un site Web. J'ai obtenu le code pour afficher aucune erreur mais quand je l'exécute dans les choses de test de Web l'application se bloque et affiche ce message d'erreur. « Le webView d'application (processus com.webview) est arrêté de façon inattendue. S'il vous plaît essayer à nouveau. Toute aide serait aprécié.Webview s'arrêtant de façon inattendue

Ci-dessous mon code pour ma classe et mon Manifest.

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 

     } 
    }); 
} 
} 

Manifest

<?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> 

débogueur montre ce ci-dessous

[2012-02-09 13:57:18 - Emulator] Type de section savevm Unknown 95

[09/02/2012 13:57:52 - WebView] HOME est en place sur l'unité 'émulateur-5554'

[09/02/2012 13:57:52 - WebView] Uploading WebView. apk sur le dispositif 'émulateur-5554'

[09/02/2012 13:57:52 - WebView] Installation WebView.apk ...

[09/02/2012 13:58:14 - WebView ] Succès!

[2012-02-09 13:58:14 - WebView] activité de départ com.webview.WebViewActivity sur l'appareil émulateur 5554

[2012-02-09 13:58:15 - WebView] ActivityManager: a partir: {intention act = android.intent.action.MAIN

cat = [android.intent.category.LAUNCHER] = cmp com.webview/.WebViewActivity}

+0

Veuillez publier l'erreur et la pile de logcat. – Pedantic

+0

Im utilisant Eclypse et nouveau à tout cela. Je n'ai aucune idée de ce que vous demandez ou comment le trouver. – CsharpBeginner

+0

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

Répondre

1

Essayez cela, ce que je faisais était de déplacer le déclaration de la WebView au main.xml et avec ce changement fonctionne bien.

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

Remerciements Je vais essayer ce matin et obtenir votre réponse. Appréciez l'aide. – CsharpBeginner

0

Vous devez mettre l'autorisation pour le WebView dans le manifeste au-dessus du c'est la permission:

le webview ne fonctionnera pas sans cette autorisation

Questions connexes