androidbrowserwebviewmenuoptionmenu

WebView not showing standard browser option menu


Good morning, I want that when the user opens my custom WebView, when he clicks the Menu Button, the standard browser's menu will appear (next, previous, share link, bookmarks, etc.).

How?

Here's my code:

   public class WebViewActivity extends Activity {
        

    private static final String TAG = "WebViewActivity";

    WebView mWebView;
    ProgressBar loadingProgressBar, loadingTitle;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        Shared.openedActivities.add(this);

        String url = this.getIntent().getExtras().getString("url");

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl(url);
        mWebView.setWebViewClient(new MyWebViewClient());

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setPluginState(PluginState.ON);
        
        loadingProgressBar = (ProgressBar) findViewById(R.id.progressbar_Horizontal);

        mWebView.setWebChromeClient(new WebChromeClient() {

            // this will be called on page loading progress
            @Override
            public void onProgressChanged(WebView view, int newProgress) {

                super.onProgressChanged(view, newProgress);

                loadingProgressBar.setProgress(newProgress);


            // hide the progress bar if the loading is complete
                if (newProgress == 100) {
                    loadingProgressBar.setVisibility(View.GONE);

                } else {
                    loadingProgressBar.setVisibility(View.VISIBLE);

                }

            }

        });

    }

    public void onDestroy() {
        super.onDestroy();
        Trace.w(TAG, "onDestroy()");

        Shared.unbindDrawables(findViewById(R.id.rootWebViewActivity));
        System.gc();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }

    private class MyWebViewClient extends WebViewClient {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            view.loadUrl(url);
            return true;
        }
    }
}

Solution

  • Sorry but that won't work, you have to implement this features by yourself. WebView is not the Browser, it is just a View to render Webpages. Everything else is a function of the Browser-App not the WebView.
    Nevertheless you can access the bookmarks of the browser as described here: Get browser history and search result in android