Discussion Forums  >  Uncategorized

Replies: 3    Views: 1403

Zoid66
Lost but trying
Profile
Posts: 176
Reg: Oct 26, 2010
USA
1,760
03/23/11 05:09 PM (14 years ago)

GeoLocation In Webview Android

Buzztouch team: I hope you can take a few and give me your thought I know 'old' 1.4 stuff.... Okay so trying to get the webview to show the location of a users when on a webpage, if the page is using GeoLocation. I am trying to figure out how to put the below code into the Screen_customURL. webView.setWebChromeClient(new WebChromeClient() { public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } });
 
Zoid66
Lost but trying
Profile
Posts: 176
Reg: Oct 26, 2010
USA
1,760
like
03/23/11 05:50 PM (14 years ago)
Forgot to add the link to the class. http://developer.android.com/reference/android/webkit/GeolocationPermissions.html So I have the min Aandroid:minSdkVersion=7PK level set to 7 to use this class.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
03/23/11 09:50 PM (14 years ago)
So.. much longer discussion needed, and I don't mind having it offline, but for now.... WebViews in Android use one of two possible setups. Either a WebViewClient or a WebChromeClient. The difference is how they process HTML, Javascript, and other browser-centric things. In most cases, programmers generally think the WebChromeClient is 'better' and more flexible. v1.4 does not use a WebChromeClient, it uses a WebViewClient. This is because chrome didn't exist (in Android) when it was written, not because it's somehow necessary or needed or whatever. Either should work but the Chrome client is needed to use what you're mentioning. So... it's a matter of 'converting' Screen_CustomerURL.java a bit. Look at that file and find where it sets the web client (around line 79), you'll see it easily. Next, visit a few URLs, like this one http://lexandera.com/2009/01/adding-alert-support-to-a-webview/ and see if you can get your head around the difference between the two approaches. If you can, cool, just change-it-up to use the Chrome Client instead. This is for sure where we are headed with 1.5. Have not done any of the HTML logic in 1.5 for Android yet. If you can get the ChromeClient running, getting the onGeoLocation part to work will be easy (with a little hacking around of course)
 
Zoid66
Lost but trying
Profile
Posts: 176
Reg: Oct 26, 2010
USA
1,760
like
03/24/11 02:08 PM (14 years ago)
Yeah that is right where I was looking at. The issue I was and still having is the the 'override' methods around the 'intent' causes errors. It's looking like more of coverting the entire class to get 'ChromeClient' to function.. I thought I had it working but the page just keep saying loading... I have been though lot's of samples etc. I'll keep at it. I have a nice travel app that will needs this function.. So it is keeping it from going live.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.