重定向到Android中使用科尔多瓦位置设置 [英] Redirect to location settings using cordova in android

查看:183
本文介绍了重定向到Android中使用科尔多瓦位置设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是什么,我想在我的科尔多瓦的android应用程序中实现的要求

Here is the requirements what i am trying to implement in my cordova android application

1。当用户进入首页检查,看看如果GPS启用。

1.When user enters the home page check to see if the gps is enabled or not.

2,如果没有启用我想指出用户在打开位置设置。

2.If not enabled i want to point the user to turn on the location settings.

第一部分是容易与GPS探测器插件,第二部分用做网络的意图plugin.But它不工作,我期望实现的。

first part is made easily with GPS detector plugin and second part is implemented using the web intent plugin.But its not working as i expected.

    if(!gps){
     //gps is disabled try to show the location setting using webintent plugin
window.plugins.webintent.startActivity({
                    action: window.plugins.webintent.ACTION_LOCATION_SOURCE_SETTINGS,
                },
                    function() {},
                    function() {
                      alert('Failed to open URL via Android Intent.');
                      console.log("Failed to open URL via Android Intent. URL: " + theFile.fullPath)
                    }
                );              
            }

我收到此错误无法通过Android的意图打开URL。     }

I am getting this error Failed to open URL via Android Intent. }

推荐答案

您可以使用实现这一目标科尔多瓦诊断-插件。一旦安装,您通过JS调用它是这样的:

You can achieve this using the cordova-diagnostic-plugin. Once installed, you call it via JS something like:

cordova.plugins.diagnostic.switchToLocationSettings();

这篇关于重定向到Android中使用科尔多瓦位置设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆