Apache Cordova3Androidプラットフォームを使用する
exectuteメソッドのGeoBroker.javaファイルで、locationManagerがインスタンス化された後、次のアクションを追加します。
if(action.equals("isGPSEnabled")){
PluginResult result;
if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER )){
result = new PluginResult(PluginResult.Status.OK);
}else{
result = new PluginResult(PluginResult.Status.ERROR);
}
callbackContext.sendPluginResult(result);
}
次に、アセットのpluginsフォルダーにあるgeolocation.jsファイルに、新しい機能を公開するように追加します
/**
* Asynchronously checks if gps is enabled.
*
* @param {Function} successCallback The function to call when gps is enabled.
* @param {Function} errorCallback The function to call when gps is not enabled. (OPTIONAL)
*/
isGPSEnabled:function(successCallback, errorCallback){
exec(successCallback, errorCallback, "Geolocation", "isGPSEnabled", []);
}
それが役に立てば幸い