Raise a Toast
package app.test;
import android.app.Activity;
import android.os.Bundle;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class Test extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
webview.getSettings().setJavaScriptEnabled(true);
// Add a client to the view
webview.setWebViewClient(mClient);
webview.loadUrl("http://www.google.com");
setContentView(webview);
}
private WebViewClient mClient = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri request = Uri.parse(url);
if (TextUtils.equals(request.getAuthority(), "www.google.com")) {
// Allow the load
return false;
}
Toast.makeText(Test.this, "Sorry, buddy", Toast.LENGTH_SHORT)
.show();
return true;
}
};
}
/*<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<form name="input" action="form.html" method="get">
Enter Email: <input type="text" id="emailAddress" />
<input type="submit" value="Submit" />
</form>
</html>*/
Related examples in the same category