F Foz Member Licensed User Longtime User Apr 18, 2019 #1 Thanks to Erel and his code here: https://www.b4x.com/android/forum/threads/webviewextras.12453/#post-102448 This enabled the webview to upload files. However, I also need the geolocation functionality. No problem, I added this to the MyChromeClient: Code: @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, true); } and I added to the manifest Code: AddPermission(android.permission.ACCESS_FINE_LOCATION) However when I check on getting the geolocation, it doesn't seem to call the onGeolocationPermissionsShowPrompt, and a call for getting the geolocation just fails. Am I missing something else? Attachments Example.zip Example.zip 4.2 KB · Views: 577
Thanks to Erel and his code here: https://www.b4x.com/android/forum/threads/webviewextras.12453/#post-102448 This enabled the webview to upload files. However, I also need the geolocation functionality. No problem, I added this to the MyChromeClient: Code: @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, true); } and I added to the manifest Code: AddPermission(android.permission.ACCESS_FINE_LOCATION) However when I check on getting the geolocation, it doesn't seem to call the onGeolocationPermissionsShowPrompt, and a call for getting the geolocation just fails. Am I missing something else?
Erel B4X founder Staff member Licensed User Longtime User Apr 19, 2019 #2 Foz said: Thanks to Erel and his code here: https://www.b4x.com/android/forum/threads/webviewextras.12453/#post-102448 Click to expand... I think that you meant to this link: https://www.b4x.com/android/forum/threads/98623/#content Are you requesting the permission with rp.CheckAndRequest? Upvote 0
Foz said: Thanks to Erel and his code here: https://www.b4x.com/android/forum/threads/webviewextras.12453/#post-102448 Click to expand... I think that you meant to this link: https://www.b4x.com/android/forum/threads/98623/#content Are you requesting the permission with rp.CheckAndRequest?
F Foz Member Licensed User Longtime User Apr 23, 2019 #3 Hi, sorry for the delay with Easter and all that. You are quite correct, I copied and pasted the wrong link - sorry about that! I'm not using rp.CheckAndRequest - I thought that just calling the callback with the parameters set to true would automatically grant the permissions, but it doesn't. I added a CheckAndRequest that is called on Activity_Resume, and I added the WebViewSetting library and set the setGeolocationEnabled to true, and the webpage now displays "Waiting on browser", and the Toast displays that the result of the check is true, but it gets no further. What else do I need to change/add to allow the geolocation to work? Attachments Example.zip Example.zip 4.4 KB · Views: 578 Upvote 0
Hi, sorry for the delay with Easter and all that. You are quite correct, I copied and pasted the wrong link - sorry about that! I'm not using rp.CheckAndRequest - I thought that just calling the callback with the parameters set to true would automatically grant the permissions, but it doesn't. I added a CheckAndRequest that is called on Activity_Resume, and I added the WebViewSetting library and set the setGeolocationEnabled to true, and the webpage now displays "Waiting on browser", and the Toast displays that the result of the check is true, but it gets no further. What else do I need to change/add to allow the geolocation to work?
F Foz Member Licensed User Longtime User Apr 23, 2019 #4 Okay, this is just weird... trying to get to the bottom of the lack of location, I've added the GPS library and I have that updating, so I can see there is a lat long being returned. I moved the code to a local file, and gave it a few more outputs so I could see where it was getting up to, and a reload so I could retry getting the location. But the webview just refuses to return a location... I'm obviously missing something, but I don't know what :/ Attachments Example.zip Example.zip 6.2 KB · Views: 531 Upvote 0
Okay, this is just weird... trying to get to the bottom of the lack of location, I've added the GPS library and I have that updating, so I can see there is a lat long being returned. I moved the code to a local file, and gave it a few more outputs so I could see where it was getting up to, and a reload so I could retry getting the location. But the webview just refuses to return a location... I'm obviously missing something, but I don't know what :/
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2019 #5 Why are you using WebView to get the location? There are much simpler and better ways to do it. Upvote 0
F Foz Member Licensed User Longtime User Apr 24, 2019 #6 Erel said: Why are you using WebView to get the location?. Click to expand... It's a stop gap solution while I'm recreating their website in an app, which needs file uploads and getting the users current location. It'll take me at least a month to do, but they need an Android app immediately, due to the website falling behind schedule. Yes, I know it's a dirty solution, but I want to buy some breathing room for the actual solution. I had figured that a webview container app would be a quickest solution, as getting the current location is the only thing that is missing. Upvote 0
Erel said: Why are you using WebView to get the location?. Click to expand... It's a stop gap solution while I'm recreating their website in an app, which needs file uploads and getting the users current location. It'll take me at least a month to do, but they need an Android app immediately, due to the website falling behind schedule. Yes, I know it's a dirty solution, but I want to buy some breathing room for the actual solution. I had figured that a webview container app would be a quickest solution, as getting the current location is the only thing that is missing.
Erel B4X founder Staff member Licensed User Longtime User Apr 25, 2019 #7 Get the location with FusedLocationProvider and send it to the server. Upvote 0