Hi I want to open this url http://3864.cloud-matic.net/ from my android webview and I have tried many ways but the app even not opens mainActivity. What I have tried is below.
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webView1);
webView.setHttpAuthUsernamePassword("cloud-matic.net/", "realm", username, password);
webView.loadUrl("http://3864.cloud-matic.net/");
}
Please give me idea where I am wrong. Ali
Not sure if this will help someone, but I implemented the onReceivedHttpAuthRequest
function(like the people above) with username and password and in every device it worked normally except on Android Oreo. Then, I realized that the Oreo phone received http requests not from the main frame and it gave me 401 error.
In the onReceivedHttpError
function I checked, if the http error is from the main frame with:
`override fun onReceivedHttpError(
view: WebView?,
request: WebResourceRequest?,
errorResponse: WebResourceResponse?
) {
super.onReceivedHttpError(view, request, errorResponse)
if(request.isForMainFrame){ //do smt. with the error}
}`
Then it started to work normally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With