I am trying to access a webpage after successfully logging in, where i get the username and password (from the EditTexts in my app user = (EditText) findViewById(R.id.user);
and pass = (EditText) findViewById(R.id.pass);
) and POST it to server.
The problem is that the webview shows the text "Authorization Required.... " (after logging in successfully) only on the phones/tablets that have android 4.2.2 but on 4.4.2, 4.4.4 and 5.0.1 works fine (shows the page intended).
I am running out of ideas and need help.
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();
if (response.getStatusLine().getStatusCode() == 200) {
//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());
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 shows - "Authorization Required. This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials(e.g., bad password), or your browser doesn't understand how to supply the credentials required." )
Later edit: Just figured out that 4.2.2 doesn't support HTML5 and that's why i got this problem.