0

Hi I am trying to load a webview that uses javascript and html5. However, I still can't access the location inside the application. I have searched through the site and found some suggestions but I am still unable to access the location. Here is my code snippet

private void openWebViewTab(){
final LinearLayout holderLayout = (LinearLayout)findViewById(R.id.home_holder);
final View myHolderView = View.inflate(MyWebViewActivity.this, R.layout.my_webview, null);
final WebView myWebView = (WebView) myHolderView.findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setGeolocationEnabled(true);
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.loadUrl(url);
}

private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
    view.loadUrl(url);
    return true;
}

}

here is my Manifestfile:

<uses-permission
    android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
    android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
    android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
    android:name="android.permission.INTERNET" />

Thanks in Advance for your help Switch

Switch
  • 131
  • 2
  • 4
  • 13
  • where is the code to access location? All this code does is load a WebView. – Suchi Jul 21 '11 at 16:07
  • Check [this][1] post and its answer for the solution. [1]: http://stackoverflow.com/questions/11280946/unable-to-get-gps-coordinates-using-javascript-on-browser-in-android/11298468#11298468 – axs Jul 02 '12 at 19:37
  • Check [this][1] post and its answers for the solution. [1]: http://stackoverflow.com/questions/11280946/unable-to-get-gps-coordinates-using-javascript-on-browser-in-android/11298468#11298468 – axs Jul 02 '12 at 19:39

1 Answers1

0

you need a instance of WebChromeClient extending. the method of onGeolocationPermissionsShowPrompt Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.

meli
  • 16