I've a problem im my actual android workingset which I don't know to handle it. I hope I'll get help here ;)
I want to fetch contents from a website (which is mine). I have to parse a single html-tag, which works perfectly fine with following source:
WebView webview = new WebView(getApplicationContext());
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new JIFace(), "HTMLOUT");
webview.setWebViewClient(new BasicWebViewClient());
webview.loadUrl("http://webaldo.at/blabla.php");
My Webviewclient looks like this:
private class BasicWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
progressRingDialog.dismiss();
doErrorDialog("Webservice Offline", "Der Webserver kann nicht erreicht werden. Bitte versuche es später nochmal.");
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if( progressRingDialog != null ) {
progressRingDialog.dismiss();
}
if( alertDialog != null ) {
alertDialog.dismiss();
}
progressRingDialog = ProgressDialog.show(Login.this, getString(R.string.progress_title), "Passwort wird überprüft", true);
TextView textView = (TextView)findViewById(R.id.statuslabel);
textView.setText("Benutzername wird geprüft");
webview.setWebViewClient(new ExtendedWebViewClient());
webview.loadUrl("javascript:window.HTMLOUT.showHTML(document.getElementsByTagName('x')[0].innerHTML);");
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
}
yes, my tag, I want to parse is
<x></x>
Now, my problem is, that I have to do not a
webview.loadUrl()
because I have to send POST params to the page using this method:
webview.postUrl("http://webaldo.at/blabla.php", EncodingUtils.getBytes("username="+username+"&password="+password, "BASE64"));
In this case, I'll get no data in my JSInterface.
Does anyone of you have similar problems, or knows a better or simplier way to handle my Username/Password autentication problem?
I'm looking forward to good answers.
Kind regards
BTW: the URL doesn't exist in this way, but that shouldn't matter. REST Services aren't supported on my webserver, therefore I have to fix it this way.