在Android中使用webview的postUrl打开浏览器后,出现白屏问题。

3

当我尝试在webView上发布Url时,前3-4秒我会看到白屏,然后浏览器打开。如果我按返回键,只会出现白屏。如果我再次按返回键,它才会回到活动页面。那么我该如何去掉这个白屏呢?以下是我的代码。

      import org.apache.http.util.EncodingUtils;
      import com.google.analytics.tracking.android.EasyTracker;
      import android.app.Activity;
      import android.os.Bundle;
      import android.view.KeyEvent;
      import android.webkit.CookieManager;
      import android.webkit.CookieSyncManager;
      import android.webkit.WebView;

     public class HtmlViewerActivity extends Activity {
         WebView wv;
         String payUrl;
       protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.web_viewer);

        wv = (WebView) findViewById(R.id.webid);

        // use cookies to remember a logged in status
        CookieSyncManager.createInstance(this);
        CookieSyncManager.getInstance().startSync();

        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeAllCookie();

                // getting data from other Activity using bundle

        Bundle bundle = new Bundle();
        bundle = getIntent().getExtras();                
        payUrl = bundle.getString("payUrl");

        wv.setKeepScreenOn(true);
        wv.getSettings().setDomStorageEnabled(true);
        wv.getSettings().setBuiltInZoomControls(true);

        byte[] post = EncodingUtils.getBytes(payUrl, "BASE64");
        wv.postUrl("http://syntheverest.collasapp/app/get_details.php", post);

      }

      @Override
      public void onBackPressed() {
          // TODO Auto-generated method stub
          if (wv.canGoBack())
              wv.goBack();
          else
              super.onBackPressed();

        }
    }

你有没有看过这个 - SweetWisher ツ
我已经尝试过了,但它仍然无法工作。问题依旧。 - Faiz Anwar
2个回答

0
尝试这个:(YourWebview).setBackgroundColor(0x00000000); 将您的 Webview 设置为透明。

谢谢,我尝试了这段代码,但问题仍然存在,只是白屏变成了透明屏。 - Faiz Anwar
1
然后,您可以实现进度条,直到出现白屏。 - Siddharth_Vyas

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接