ログインに成功した後、Web ページにアクセスしようとしています。ここで、ユーザー名とパスワードを取得します (アプリの EditTexts から "user = (EditText) findViewById(R.id.user);" および "pass = (EditText) findViewById (R.id.pass);" ) そしてサーバーに POST します。
問題は、Android 4.2.2 を搭載しているが 4.4.2、4.4.4、および 5.0.1 では正常に動作する携帯電話/タブレットでのみ、(正常にログインした後に) webview に "Authorization Required...." というテキストが表示されることです。 (意図したページを表示します)。
アイデアが不足しており、助けが必要です。手伝ってくれませんか?前もって感謝します。
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("user", user.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("password", pass.getText().toString()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
httppost.addHeader("Authorization", "Basic BLA123BLA23BLA32343LSJ");
// Execute HTTP Post Request
response = httpclient.execute();
//WebView
webview_asd = new WebView(MainScreen.this);
webview_asd = (WebView) findViewById(R.id.webview_asd);
webview_asd.getSettings().setLoadsImagesAutomatically(true);
webview_asd.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webview_asd.setWebViewClient( new WebViewClient() );
webview_asd.getSettings().setJavaScriptEnabled(true);
CookieSyncManager.createInstance (webview_asd.getContext());
CookieSyncManager.getInstance().sync();
cookies = ((AbstractHttpClient) httpclient).getCookieStore().getCookies();
if(cookies != null)
{
for(Cookie cookie : cookies)
{
cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain();
CookieManager.getInstance().setCookie(cookie.getDomain(), cookieString);
}
}
CookieSyncManager.getInstance().sync();
webview_asd.loadURL(URL);
webview_asd.setVisibility(View.VISIBLE);
WebView ページには、「承認が必要です。このサーバーは、要求されたドキュメントにアクセスする権限があることを確認できませんでした。提供した資格情報が間違っている (パスワードが間違っているなど) か、必要な資格情報を提供する方法をブラウザーが認識していません。 "
後で編集: 4.2.2 が HTML5 をサポートしていないことがわかったので、この問題が発生しました。