如何在android中设置webView之前登录wordpress网站

时间:2017-10-22 12:48:16

标签: android authentication http-authentication

我有一个wordpress网站。我想将webView转换为需要身份验证的页面。如何设置用户登录?

请帮帮我

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                     Bundle savedInstanceState) {
    WebView wvCourse = (WebView) mainview.findViewById(R.id.wvCourse);
    wvCourse.loadUrl(url);
    WebSettings settings = wvCourse.getSettings();
    settings.setDomStorageEnabled(true);
    wvCourse.getSettings().setJavaScriptEnabled(true);
    wvCourse.setWebViewClient(new MyWebViewClient());
    return mainview;
}

public class MyWebViewClient extends WebViewClient {

    public void TestFunction() {
        Log.e("username", pref.getString("username_val", ""));
        Log.e("here","here");
    }

    @Override
    public void onReceivedHttpAuthRequest(WebView view,
                                      HttpAuthHandler handler, String host, String realm) {
        TestFunction();
        handler.proceed("user123","user_123");
    }
}

0 个答案:

没有答案