安卓开启GPS,native.js
if(plus.os.name == "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);
var gpsProvider = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);//检查是否开启了GPS
if(!gpsProvider) {
var message = "为了获取您的精准位置,请开启GPS设备。";
var title = "GPS未启用";
var alertCB = function () {
var Intent = plus.android.importClass("android.content.Intent");
var mIntent = new Intent('android.settings.LOCATION_SOURCE_SETTINGS');
main.startActivity(mIntent);//打开GPS设置
}
plus.nativeUI.alert( message, alertCB, title);
}
}