简体   繁体   English

适用于Android的WebViewClient问题

[英]WebViewClient issues for android

WebViewPage.java WebViewPage.java

   package com.srccodes.androidprojects;
   import android.os.Bundle;
   import android.annotation.SuppressLint;
   import android.app.Activity;
   import android.view.Menu;
   import android.webkit.WebChromeClient;
   import android.webkit.WebSettings.PluginState;
   import android.webkit.WebView;
   import android.webkit.WebViewClient;

 //*******************************************************************************

      public class WebViewPage extends Activity {

      // *******************************************************************************

private WebView webView;

// *******************************************************************************

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view_page);
    webView = (WebView) findViewById(R.id.webView1);

// ******************************************************************************

webView.setWebViewClient(new WebViewClient());  
  webView.getSettings().setJavaScriptEnabled(true);                                     
    webView.getSettings().setPluginState(PluginState.ON);           
    webView.getSettings().setLoadsImagesAutomatically(true); 
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);       
    webView .setKeepScreenOn(true);         
    webView .setInitialScale(100);      
    webView .getSettings().setUseWideViewPort(true);          
    webView .setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);     
    webView.getSettings().setBuiltInZoomControls(true);     
    webView.setWebChromeClient(new WebChromeClient());               
    webView.getSettings().setDomStorageEnabled(true);           
    webView.loadUrl("http://192.168.2.15:8090/ICUAlerts/jsp/Index/index.jsp");    
}

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_web_view_page, menu);
    return true;
}
}

This is my code for hiding address bar in android.. 这是我的代码,用于在android中隐藏地址栏。

I Login my page in one orientation after changing this orientation(either vertical or horizontal) it may signout why?Please edit this code... 更改此方向(垂直或水平)后,我以一个方向登录页面,可能会退出原因?请编辑此代码...

I used a javascript calendar in application If without webView.setWebViewClient(new WebViewClient()); 我在应用程序中使用了JavaScript日历,如果没有webView.setWebViewClient(new WebViewClient()); Javascript calendar working but using this webviewclient it doesn't work Javascript日历有效,但使用此webviewclient无效

And my layout file is 我的布局文件是

<WebView  

xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

I think the logout is because your change in orientation reloads the activity, and from start you are not logged in. Try this : 我认为注销是因为您对方向的更改会重新加载活动,并且从一开始您就没有登录。请尝试以下操作:

Android WebView: handling orientation changes Android WebView:处理方向更改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM