Parveen Dalal
Parveen Dalal

Reputation: 21

Android WebView Screen Goes black during load the next or same page

We made an android application for samsung galaxy tab using webview but when we hit the same page or a different page in between we got a black screen for 4-5 seconds after that screen shows the page. So please tell me what we do for this i don't want that black screen. Kindly find the below code for the same.

CallKiosk.java

package one97.kiosk;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class CallKiosk extends Activity {
    public final String url = "http://10.0.8.178:8088/Kiosk/";
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webview = new WebView(this);
        webview.getSettings().setJavaScriptEnabled(true); 
        webview.setWebViewClient(new WebViewClient());
        setContentView(webview); 
        webview.loadUrl(url); 
    }
    private class MyWebViewClient extends WebViewClient {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    }
}

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

AndroidManifest.xml

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

    <application android:icon="@drawable/logo" android:label="@string/app_name">
        <activity android:name=".CallKiosk"
                  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>

Upvotes: 2

Views: 1357

Answers (1)

Yousef Zakher
Yousef Zakher

Reputation: 1544

Try this if useful, webvieew.setBackgroundColor("#FFFFFF")

Upvotes: 1

Related Questions