【问题标题】:Getting white screen then after browser open using webview postUrl in Android在Android中使用webview postUrl打开浏览器后出现白屏
【发布时间】:2013-11-20 00:50:54
【问题描述】:

当我尝试在 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();

        }
    }

【问题讨论】:

  • 你检查this???
  • 我试过了,还是不行。

标签: android webview http-post android-browser


【解决方案1】:

试试这个:(YourWebview).setBackgroundColor(0x00000000);

将您的网络视图设置为透明。

【讨论】:

  • 谢谢,我试过这段代码,但问题仍然相同,只是代替白屏我得到透明屏幕。
  • 然后你可以实现进度条直到出现白屏。
【解决方案2】:

是的,正如 sid 所说,您可以使用进度条。

webview with progressbar

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-29
    • 2014-03-12
    • 2021-06-12
    • 2016-12-29
    • 1970-01-01
    相关资源
    最近更新 更多