I'm making an Android application using Geolocation.
Geolocation seems to support HTml better than Android, so Android simply loaded the HTml file on the sdcard, and the imported HTml file was implemented to use Geolocation to track the location.
But when I go into Chrome, I can't track the location, and user denied appears, so I want to run it with another browser, but if I keep running it, it seems to run in Chrome.
I've summarized the solutions. Please reply.
Thank you.
android map
To use Geolocation in Webview, you need several settings, such as JavaScript and Geolocation Permissions.Callback.
//set JavaScript to work
webview.getSettings().setJavaScriptEnabled(true);
//Authorize Geolocaion to use
webView.setWebChromeClient(new WebChromeClient() {
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
}
});
© 2024 OneMinuteCode. All rights reserved.