Cordova 诊断插件 switchToLocationSettings()

Mal*_*iof 5 jquery android cordova

我从事cordova jquery 移动项目。

我想知道是否可以在触发 switchToLocationSettings() 函数后进行回调。

我想知道用户是否在他的设备上启用了 GPS。

我像这样使用它:

cordova.plugins.diagnostic.switchToLocationSettings();
Run Code Online (Sandbox Code Playgroud)

但我想要这样的东西:

cordova.plugins.diagnostic.switchToLocationSettings(Success,Error);
Run Code Online (Sandbox Code Playgroud)

是否可以?

小智 1

根据Java Code,没有callback method此功能。检查下面 -

    /**
 * Requests that the user enable the location in device settings.
 */
public void switchToLocationSettings() {
    Log.d(LOG_TAG, "Switch to Location Settings");
    Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    ctx.startActivity(settingsIntent);
}
Run Code Online (Sandbox Code Playgroud)

这就是为什么你无法callback function在此传递任何额外内容method。你必须自己写code