我是靠谱客的博主 优美夕阳,这篇文章主要介绍uniapp如何判断手机定位是否开启,现在分享给大家,希望可以做个参考。

本教程操作环境:windows7系统、uni-app2.5.1版本,Dell G3电脑。

推荐(免费):uni-app开发教程

uniapp判断手机定位是否开启的方法:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**检查是否打开GPS功能(android)**/ export const checkOpenGPSServiceByAndroid = () => { let system = uni.getSystemInfoSync();// 获取系统信息 if (system.platform === 'android') { // 判断平台 var context = plus.android.importClass("android.content.Context"); var locationManager = plus.android.importClass("android.location.LocationManager"); var main = plus.android.runtimeMainActivity(); var mainSvr = main.getSystemService(context.LOCATION_SERVICE); if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) { uni.showModal({ title: '提示', content: '请打开定位服务功能', showCancel: false, // 不显示取消按钮 success() { if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) { var Intent = plus.android.importClass('android.content.Intent'); var Settings = plus.android.importClass('android.provider.Settings'); var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); main.startActivity(intent); // 打开系统设置GPS服务页面 } else { console.log('GPS功能已开启'); } } }); } } }
登录后复制

以上就是uniapp如何判断手机定位是否开启的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是优美夕阳最近收集整理的关于uniapp如何判断手机定位是否开启的全部内容,更多相关uniapp如何判断手机定位是否开启内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(312)

评论列表共有 0 条评论

立即
投稿
返回
顶部