WebView causes errors in the second activity

I have the following code that works fine when I have this in my main activity:

    WebView webView = (WebView)findViewById(R.id.iQuestionWebView);
    webView.loadDataWithBaseURL(null, "test", "text/html", "utf-8", null);

Where the WebView layout looks something like this:

<WebView
    android:id="@+id/iQuestionWebView"
    android:layout_width="match_parent"
    android:layout_height="200dp"/>

But if I put the layout and code in my second activity (simple LinearLayout), I get the following errors:

netstack: LIB_MGR - Error loading lib libdnshostprio.so

netstack: STAT_HUB - Failed to load plugin: libdnshostprio.so

netstack: LIB_MGR - Error loading lib spl_proc_plugin.so

netstack: STAT_HUB - Failed to load plugin: spl_proc_plugin.so

netstack: LIB_MGR - Error loading lib pp_proc_plugin.so

netstack: STAT_HUB - Failed to load plugin: pp_proc_plugin.so

netstack: STAT_HUB - com.ms.wvtest application is not supported

E / cutils-trace (11142): Error opening trace file: permission denied (13)

, - , :

MainActivity.java

public class MainActivity extends Activity 
{
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final Button startQuiz = (Button)findViewById(R.id.iMainStartQuizButton);
        startQuiz.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                Intent intent = new Intent(MainActivity.this, Quiz.class);
                startActivity(intent);
            }
        });
    }
}

Quiz.java

public class Quiz extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.quiz);

        WebView webView = (WebView)findViewById(R.id.iQuestionWebView);
        webView.loadDataWithBaseURL(null, "test", "text/html", "utf-8", null);
    }
}

, - . !

: quiz.xml :

quiz.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <WebView
        android:id="@+id/iQuestionWebView"
        android:layout_width="match_parent"
        android:layout_height="200dp"/>

</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ms.studycards"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/l_app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.ms.studycards.MainActivity"
            android:label="@string/l_setup_title" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.ms.studycards.Quiz"
            android:label="@string/l_quiz_title"
            android:parentActivityName="com.ms.studycards.MainActivity">
        </activity>
    </application>

</manifest>
+4
1

, ( ).

  • :

    uses-permission android:name="android.permission.INTERNET"
    
  • - ( Quiz.java) javascript:

    webView.getSettings().setJavaScriptEnabled(true);
    

2 ( YouTube ) - .

+2

All Articles