WebSettings.SetGeolocationEnabled(Boolean) 方法

定义

设置是否启用地理位置。

[Android.Runtime.Register("setGeolocationEnabled", "(Z)V", "GetSetGeolocationEnabled_ZHandler")]
public abstract void SetGeolocationEnabled(bool flag);
[<Android.Runtime.Register("setGeolocationEnabled", "(Z)V", "GetSetGeolocationEnabled_ZHandler")>]
abstract member SetGeolocationEnabled : bool -> unit

参数

flag
Boolean

是否应启用地理位置

属性

注解

设置是否启用地理位置。 默认为 true

请注意,为了使地理位置 API 可供 WebView 中的页面使用,必须满足以下要求:<ul><li>应用程序必须具有访问设备位置的权限,请参阅android.Manifest.permission#ACCESS_COARSE_LOCATIONandroid.Manifest.permission#ACCESS_FINE_LOCATION<li>应用程序必须提供回调的WebChromeClient#onGeolocationPermissionsShowPrompt实现,以接收页面通过 JavaScript 地理位置 API 请求访问位置的通知。 </ul>

适用于 . 的 android.webkit.WebSettings.setGeolocationEnabled(boolean)Java 文档

本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。

适用于