0

i have a hybrid app. I used web-view to make a android hybrid app. I also have a native menubar above the webview. My question is, How can i disable the native menu from my web application? Is it possible? If yes please share your thoughts on this

31piy
  • 23,323
  • 6
  • 47
  • 67
JustCode
  • 661
  • 1
  • 8
  • 19

3 Answers3

1

Check the answer of this question, as they provide snippet code to call Java method from javascript in Android, this will help you if you create a Java method that will disable your ImageButton from a Javascript

Call Java function from JavaScript over Android WebView

  • Since there is limitation, I cant change any code from native side. I want to do it only through my web application using javascript. – JustCode Mar 21 '18 at 10:29
  • What limitation? do you have the access to the ImageView in your native code? if so you can disable it. if you don't have the Id of the imageView so there is no way possible for change it's state – Amine ABDALKHALKI Mar 21 '18 at 10:33
  • Amine ABDALKHALKI - i cant change any code in native but i know the id of ImageButton. All i want is without changing any code in native, i want to disable the Imagebutton from my javascript – JustCode Mar 21 '18 at 10:53
  • from Javascript you can't change a "thing" without calling a native code.. i hope it's clear for you – Amine ABDALKHALKI Mar 21 '18 at 11:03
  • 1
    ohhh :( thank you for responding :) Amine ABDALKHALKI – JustCode Mar 21 '18 at 11:15
1

You will need to find the user-agent click here to see how to check useragent then u can write a simple javascript function on page load to disable your header

Vijay
  • 169
  • 7
1

Try to set webviewclient to your webview and override onPageFinished like this. In my project I tried to hide google and facebook buttons on fitbit page.

    webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                if (!TextUtils.isEmpty(url) && url.contains("fitbit")) {
                    view.loadUrl("javascript: setTimeout(function () { $('.external-choices,.or').hide();} , 1000) ");//JS to hide the fitbit login from G+ and FB
                }
            }
}
Ravi
  • 171
  • 2
  • 8
  • Since there is limitation, I cant change any code from native side. I want to do it only through my web application using javascript. – JustCode Mar 21 '18 at 10:29
  • Could you please post screenshot, if you are trying to hide action bar can't you set the theme of that activity which holds your webview accordingly – Ravi Mar 22 '18 at 10:20