javascript - Nativescript Vue.js 定位 GPS
问题描述
我最近使用原生 vue.js 开发了一个 Android 应用程序。
我使用了地理定位插件,它可以在具有 google play 服务的设备上完美运行,但不能在禁用 Google 服务的设备上运行。
我正在寻找一个可以在没有 Google 服务的设备上进行定位的模块。
需要你的帮助。
解决方案
尝试这个,
import * as application from "application";
const PLAY_SERVICES_RESOLUTION_REQUEST = 9999;
...
isGooglePlayServicesAvailable() {
const googleApiAvailability = com.google.android.gms.common.GoogleApiAvailability.getInstance();
const resultCode = googleApiAvailability.isGooglePlayServicesAvailable(application.android.context);
if (resultCode != com.google.android.gms.common.ConnectionResult.SUCCESS) {
if (googleApiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(application.android.context, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
}
return false;
}
return true;
}
...
如果不可用,它将通知并安装播放服务。
推荐阅读
- python - 如果 linux 中的活动窗口发生变化,则执行 python 代码
- go - 从子文件夹导入函数
- python - 如何在 python 中有效地存储、检查包含和检索大量浮点数?
- ios - 使用 Rect Native RNIAP 包启动 App Store 应用内购买对话框为时已晚
- algorithm - Google Kickstart Round A 2021-Rabbit House
- ibm-midrange - 基于条件的命令参数填写提示
- amazon-web-services - 在本地运行由 cdk 创建的嵌套堆栈
- spring-boot - Heroku Spring boot buildpack 映像应用程序未启动
- c# - 添加大参数时,ado.net 更新语句超时
- react-native - 从 expo cli 弹出以响应本机 cli 时遇到错误