R Ram Member Licensed User Longtime User May 14, 2012 #1 when pointing webview to a page that has this kind of function: Code: Copy <html> <head> <script type="text/javascript"> // Check for geolocation support if (navigator.geolocation) { // Use method getCurrentPosition to get coordinates navigator.geolocation.getCurrentPosition(function (position) { // Access them accordingly document.getElementById("Latitude").value = position.coords.latitude; document.getElementById("Longitude").value = position.coords.longitude; }); } else alert("no geo-location support"); </script> </head> <body> Latitude:<input type="text" id="Latitude" name="Latitude" value="?" /> Longitude:<input type="text" id="Longitude" name="Longitude" value="?" /> </body> </html> with most browsers i get "would you like to share your location?" and if agree then get the location in return, however when using webview i get the page without any alert, share permission question nor results.. any advice will be highly appreciated! :sign0085: Thx & Best, R.
when pointing webview to a page that has this kind of function: Code: Copy <html> <head> <script type="text/javascript"> // Check for geolocation support if (navigator.geolocation) { // Use method getCurrentPosition to get coordinates navigator.geolocation.getCurrentPosition(function (position) { // Access them accordingly document.getElementById("Latitude").value = position.coords.latitude; document.getElementById("Longitude").value = position.coords.longitude; }); } else alert("no geo-location support"); </script> </head> <body> Latitude:<input type="text" id="Latitude" name="Latitude" value="?" /> Longitude:<input type="text" id="Longitude" name="Longitude" value="?" /> </body> </html> with most browsers i get "would you like to share your location?" and if agree then get the location in return, however when using webview i get the page without any alert, share permission question nor results.. any advice will be highly appreciated! :sign0085: Thx & Best, R.
Erel B4X founder Staff member Licensed User Longtime User May 14, 2012 #2 Try to use WebViewExtra: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras.html#post70053 The standard WebView doesn't support modal dialogs. It may be related (I'm not sure). Upvote 0
Try to use WebViewExtra: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras.html#post70053 The standard WebView doesn't support modal dialogs. It may be related (I'm not sure).
R Ram Member Licensed User Longtime User May 14, 2012 #3 Erel said: Try to use WebViewExtra: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras.html#post70053 The standard WebView doesn't support modal dialogs. It may be related (I'm not sure).[/QUOTE thx for your reply, I did try it but couldn't amanage to get it to work either.. Perhaps it can be done with webextraview but I couldn't. Click to expand... Upvote 0
Erel said: Try to use WebViewExtra: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras.html#post70053 The standard WebView doesn't support modal dialogs. It may be related (I'm not sure).[/QUOTE thx for your reply, I did try it but couldn't amanage to get it to work either.. Perhaps it can be done with webextraview but I couldn't. Click to expand...
warwound Expert Licensed User Longtime User May 14, 2012 #4 As Erel pointed out - the default B4A WebView does not support modal dialogs. So if the javascript navigator.geolocation returns false then the alert dialog will not be displayed. And if the javascript use of navigator.geolocation would normally show a prompt (to allow/disallow) then that prompt will not be displayed either. So you need to add the WebChromeClient to your WebView to enable modal dialogs. But WebViewExtras will i think need an update. Take a look at the documentation: WebChromeClient | Android Developers. Scroll down that page to onGeolocationPermissionsHidePrompt and onGeolocationPermissionsShowPrompt. It looks as though i'll need to implement those two methods in WebViewExtras so that the WebChromeClient properly asks the user for permission for the web page to use the Geolocation methods. Can you try to simply use WebViewExtras and it's addWebChromeClient method and post with your results? It may be that the default WebChromeClient already shows the required dialogs but i suspect not. Post again with your results and if required i'll try and update the WebChromeClient to support the Geolocation prompts. Martin. Upvote 0
As Erel pointed out - the default B4A WebView does not support modal dialogs. So if the javascript navigator.geolocation returns false then the alert dialog will not be displayed. And if the javascript use of navigator.geolocation would normally show a prompt (to allow/disallow) then that prompt will not be displayed either. So you need to add the WebChromeClient to your WebView to enable modal dialogs. But WebViewExtras will i think need an update. Take a look at the documentation: WebChromeClient | Android Developers. Scroll down that page to onGeolocationPermissionsHidePrompt and onGeolocationPermissionsShowPrompt. It looks as though i'll need to implement those two methods in WebViewExtras so that the WebChromeClient properly asks the user for permission for the web page to use the Geolocation methods. Can you try to simply use WebViewExtras and it's addWebChromeClient method and post with your results? It may be that the default WebChromeClient already shows the required dialogs but i suspect not. Post again with your results and if required i'll try and update the WebChromeClient to support the Geolocation prompts. Martin.
R Ram Member Licensed User Longtime User May 14, 2012 #5 will do @Martin thank you very much for your answer! i will re try and post my results once ill have some progress, once again, thx much! Upvote 0
will do @Martin thank you very much for your answer! i will re try and post my results once ill have some progress, once again, thx much!
R Ram Member Licensed User Longtime User May 14, 2012 #6 no joy @Martin using addWebChromeClient did help me with my tests to show java scripts alerts msg's from my web page but it does not show the permission alert. I found this code that automatically allow the location permission but i have absolutely no clue on how to implement it or if its possible all together :sign0104:: Code: Copy mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin,true,false); } }); } Upvote 0
no joy @Martin using addWebChromeClient did help me with my tests to show java scripts alerts msg's from my web page but it does not show the permission alert. I found this code that automatically allow the location permission but i have absolutely no clue on how to implement it or if its possible all together :sign0104:: Code: Copy mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin,true,false); } }); }
warwound Expert Licensed User Longtime User May 15, 2012 #7 Here you go, an updated WebViewExtras: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras-2.html#post102448. Martin. Upvote 0
Here you go, an updated WebViewExtras: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras-2.html#post102448. Martin.
R Ram Member Licensed User Longtime User May 15, 2012 #8 warwound said: Here you go, an updated WebViewExtras: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras-2.html#post102448. Martin. Click to expand... YOU ROCK!!!!!!!!!! :sign0060::sign0060::sign0060::sign0060::wav: enjoy the beer my friend. Last edited: May 15, 2012 Upvote 0
warwound said: Here you go, an updated WebViewExtras: http://www.b4x.com/forum/additional-libraries-official-updates/12453-webviewextras-2.html#post102448. Martin. Click to expand... YOU ROCK!!!!!!!!!! :sign0060::sign0060::sign0060::sign0060::wav: enjoy the beer my friend.