Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
ShuDaoPathWeb
Commits
5e1b379f
Commit
5e1b379f
authored
Jun 06, 2025
by
p x
Browse files
炮筒
parent
4e1a44cb
Changes
4
Show whitespace changes
Inline
Side-by-side
app/src/main/java/com/sd/shupathwebview/MainActivity.kt
View file @
5e1b379f
...
...
@@ -10,6 +10,9 @@ import android.view.KeyEvent
import
android.webkit.ConsoleMessage
import
android.webkit.SslErrorHandler
import
android.webkit.WebChromeClient
import
android.webkit.WebResourceError
import
android.webkit.WebResourceRequest
import
android.webkit.WebResourceResponse
import
android.webkit.WebSettings
import
android.webkit.WebView
import
android.webkit.WebViewClient
...
...
@@ -50,9 +53,9 @@ class MainActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
// enableEdgeToEdge()
binding
=
ActivityMainBinding
.
inflate
(
layoutInflater
)
AMapLocationClient
.
updatePrivacyShow
(
this
,
true
,
true
)
AMapLocationClient
.
updatePrivacyAgree
(
this
,
true
)
aMapLoc
.
initLocation
()
//
AMapLocationClient.updatePrivacyShow(this,true,true)
//
AMapLocationClient.updatePrivacyAgree(this,true)
//
aMapLoc.initLocation()
CustomLog
.
clearLog
()
setContentView
(
binding
.
root
)
requestPers
()
...
...
@@ -163,8 +166,10 @@ class MainActivity : AppCompatActivity() {
setAllowUniversalAccessFromFileURLs
(
true
)
}
// val url = "file:///android_asset/dist/index.html"
val
url
=
"http://82.156.182.48:8088/3dmap/"
// val url = "https://172.29.128.38:13443/shudao-navigation3d-app/index"
// val url = "www.baidu.com"
// val url = "http://82.156.182.48:8088/3dmap/"
// val url = "https://10.149.230.104:19443/shudao-navigation3d-app/index"
val
url
=
"https://172.29.128.38:13443/shudao-navigation3d-app/index"
binding
.
dwebview
.
loadUrl
(
url
)
binding
.
dwebview
.
webViewClient
=
object
:
WebViewClient
()
{
...
...
@@ -177,6 +182,22 @@ class MainActivity : AppCompatActivity() {
// super.onReceivedSslError(view, handler, error)
handler
?.
proceed
()
}
override
fun
onReceivedError
(
view
:
WebView
?,
request
:
WebResourceRequest
?,
error
:
WebResourceError
?
)
{
super
.
onReceivedError
(
view
,
request
,
error
)
}
override
fun
onReceivedHttpError
(
view
:
WebView
?,
request
:
WebResourceRequest
?,
errorResponse
:
WebResourceResponse
?
)
{
super
.
onReceivedHttpError
(
view
,
request
,
errorResponse
)
}
}
binding
.
dwebview
.
webChromeClient
=
object
:
WebChromeClient
()
{
...
...
app/src/main/java/com/sd/shupathwebview/viewmodels/AMapLoc.kt
View file @
5e1b379f
...
...
@@ -60,7 +60,7 @@ class AMapLoc @Inject constructor(@ApplicationContext var context: Context) : Vi
mOption
.
setLocationMode
(
AMapLocationMode
.
Hight_Accuracy
)
//可选,设置定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式
mOption
.
setGpsFirst
(
false
)
//可选,设置是否gps优先,只在高精度模式下有效。默认关闭
mOption
.
setHttpTimeOut
(
30000
)
//可选,设置网络请求超时时间。默认为30秒。在仅设备模式下无效
mOption
.
setInterval
(
1000
)
//可选,设置定位间隔。默认为2秒
mOption
.
setInterval
(
1000
)
//可选,设置定位间隔。默认为2秒
最快1秒,低于1秒还是1秒
mOption
.
setNeedAddress
(
false
)
//可选,设置是否返回逆地理地址信息。默认是true
mOption
.
setOnceLocation
(
false
)
//可选,设置是否单次定位。默认是false
mOption
.
setOnceLocationLatest
(
false
)
//可选,设置是否等待wifi刷新,默认为false.如果设置为true,会自动变为单次定位,持续定位时不要使用
...
...
@@ -154,7 +154,7 @@ class AMapLoc @Inject constructor(@ApplicationContext var context: Context) : Vi
//解析定位结果,
val
result
=
sb
.
toString
()
CustomLog
.
d
(
TAG
,
result
)
//
CustomLog.d(TAG, result)
setMyLocation
(
location
,
result
)
}
else
{
CustomLog
.
d
(
TAG
,
"定位失败,loc is null"
)
...
...
app/src/main/res/layout/activity_main.xml
View file @
5e1b379f
...
...
@@ -12,7 +12,7 @@
android:id=
"@+id/dwebview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:visibility=
"gone"
/>
/>
...
...
app/src/main/res/xml/network_security_config.xml
View file @
5e1b379f
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config
cleartextTrafficPermitted=
"true"
/>
<domain-config
cleartextTrafficPermitted=
"true"
>
<domain
includeSubdomains=
"true"
>
minedata.cn
</domain>
<domain
includeSubdomains=
"true"
>
82.156.182.48
</domain>
</domain-config>
</network-security-config>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment