Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Android WebView to make it work identically Android browser?

What are the settings to enable or disable in WebView to do this?

like image 949
Igor Kostenko Avatar asked Oct 29 '25 13:10

Igor Kostenko


2 Answers

If you want to use a webview with exactly the same features as the native android browser, you have to check MANY options and settings. A WebView is made to NOT use all of the browsers options and settings for better performance and for having more controll on what the users can and can not do while browsing. to figure out all the opportunities you should read through the api documentation here: http://developer.android.com/reference/android/webkit/WebView.html

For some further dealing and handling with the WebView class also here are some usefull sample codelines: http://pankajchunchun.wordpress.com/2013/01/09/example-of-webview-with-result-handler-and-connection-timeout-handler/

I hope this will help you.

like image 107
Forke Avatar answered Oct 31 '25 03:10

Forke


this is the webview example source..

what kind of setting do you wanna know??

public class MainActivity extends Activity {
    WebView webview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webview = (WebView)findViewById(R.id.webview);
        webview.setWebViewClient(new WebClient()); 
        WebSettings set = webview.getSettings();
        set.setJavaScriptEnabled(true);
        set.setBuiltInZoomControls(true);
        webview.loadUrl("http://www.google.com");

        findViewById(R.id.btnStart).setOnClickListener(onclick);
    }

    OnClickListener onclick =new OnClickListener() {

        @Override
        public void onClick(View v) {
            String url= null;
            EditText add = (EditText)findViewById(R.id.add);
            url = add.getText().toString();
            webview.loadUrl(url);           
        }
    };

    class WebClient extends WebViewClient {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
like image 44
Ssam Avatar answered Oct 31 '25 03:10

Ssam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!