1

アプリ ビューを起動した瞬間に yahoo メールを開く予定のテスト webview アプリを作成しています。これは、ユーザー名とパスワードをハードコードしたい Web ビューになります。yahoo が post ではなく get メソッドを使用していることは知っています。これを達成する方法はありますか?これまでの私のコードは次のとおりです。

Webview webview = (WebView) getView().findViewById(R.id.mywebview);
webview.setBackgroundColor(0);
            webview.getSettings().setJavaScriptEnabled(true);

            webview.setWebViewClient(new webClient());
            String url = "https://www.yahoomail.com";
            webview.loadUrl(url);

private class webClient extends WebViewClient {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            view.setVisibility(View.VISIBLE);

        }
        @Override
        public void onPageFinished(WebView view, String url) {

            final Animation fade = new AlphaAnimation(0.0f, 1.0f);
            fade.setDuration(200);
            view.startAnimation(fade);

            view.setVisibility(View.VISIBLE);

        }
        public void animate(final WebView view) {
            final Animation anim = AnimationUtils.loadAnimation(getActivity(),
                    R.anim.slide_in_from_left);
            view.startAnimation(anim);
        }
        @Override
        public void onReceivedError( WebView view, int errorCode, String description, String failingUrl ) {
            Toast.makeText(view.getContext(), "Authentication Error", Toast.LENGTH_LONG).show();
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.setCookie("yahooemail@yahoo.com", "yahoopass");
            super.onReceivedError(view, errorCode, description, failingUrl);
        }

        @Override
        public void onLoadResource( WebView view, String url ){

        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            return super.shouldOverrideUrlLoading(view, url);

        }

        @Override
        public void onReceivedHttpAuthRequest( WebView view, final HttpAuthHandler handler, final String host, final String realm ){

            handler.proceed("yahooemail@yahoo.com", "yahoopass");

        }

    }
4

1 に答える 1