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);
r=mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);
上面这一段代码只能判断系统是否有打开gps开关,并不能判断应用程序是否有位置权限?
尝试用下面的代码去检查权限
var Context = plus.android.runtimeMainActivity();
var res = plus.android.invoke("android.support.v4.app.ActivityCompat", "checkSelfPermission", Context, "android.permission.ACCESS_FINE_LOCATION");
报如下错误:
Uncaught Attempt to invoke virtual method 'java.lang.Class java.lang.reflect.Method.getReturnType()' on a null object reference;at static android.support.v4.app.ActivityCompat.checkSelfPermission
请问这个怎么整呀,或者怎么判断程序是否有获取位置权限?
Lspring
导入的这个android.support.v4.app.ActivityCompat没有checkSelfPermission这个方法吧,这个方法对应的类是android.support.v4.content.ContextCompat或者mui的类io.dcloud.common.adapter.util.PermissionUtil
2018-08-23 11:19