OS 6.0 之前的 Titanium Android 地理定位权限
Titanium Android Geolocation Permission for OS older than 6.0
因此,我已成功获得适用于 Android 6.0 及更高版本的地理定位许可,但我无法使其适用于 Android 4.4.4。
我不断在控制台中收到这些错误
dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
[DEBUG] : dalvikvm: VFY: replacing opcode 0x6e at 0x0002
[INFO] : dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
这是来自这个
var hasLocationPermissions = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
现在我在TiApp.xml
中添加了以下权限
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.NoActionBar"/>
<!-- Camera Permissions -->
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
</manifest>
</android>
仍然没有运气。这是我用来执行此操作的代码。我什至试图通过检查版本来规避
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;
Titanium.Geolocation.purpose = 'Get Current Location to search local Items';
var hasLocationPermissions = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
if (Titanium.Platform.model != "Simulator"){
Ti.API.info("ANDROID VERSION:"+Ti.Platform.version);
if(Alloy.Globals.versionCompare(Ti.Platform.version, "6.0") == -1){
getCurrentPosition();
} else
{
if(hasLocationPermissions == true){
getCurrentPosition();
} else {
var win = Alloy.createController('locationPermission', {callback: function(e){
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
if (e.success) {
getCurrentPosition();
} else {
Alloy.Globals.createAlertDialog('There seem to be issues with determining your location.\Please enable Location Services in your Settings to use Fluid');
}
});
}}).getView();
win.open();
}
}
} else {
Ti.API.info("LOCATION FOR SIMULATOR SET TO GALVANIZE - 1644 PLATTE DENVER");
Alloy.Globals.currentLocation = {attributes:{coordinates:{"lat": 39.757885, "lng": -105.0082375}}};//Galvanize
if(successCallback) successCallback();
}
有人解决了吗?我在 5.2.0 GA
根据我的经验android 6 之前的版本,或 23 以下的 SDK 版本,在安装时继续询问所有权限。因此,只有 android 6 及更高版本或 SDK 23 及更高版本才需要使用此功能时的新权限请求。当说请求位置时,我的 5.3GA 应用程序请求棉花糖的权限,但版本 <6 的手机像往常一样在安装时请求权限。我的代码没有任何基于 android 版本的条件逻辑。
因此,我已成功获得适用于 Android 6.0 及更高版本的地理定位许可,但我无法使其适用于 Android 4.4.4。
我不断在控制台中收到这些错误
dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
[DEBUG] : dalvikvm: VFY: replacing opcode 0x6e at 0x0002
[INFO] : dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
这是来自这个
var hasLocationPermissions = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
现在我在TiApp.xml
中添加了以下权限<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.NoActionBar"/>
<!-- Camera Permissions -->
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
</manifest>
</android>
仍然没有运气。这是我用来执行此操作的代码。我什至试图通过检查版本来规避
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;
Titanium.Geolocation.purpose = 'Get Current Location to search local Items';
var hasLocationPermissions = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
if (Titanium.Platform.model != "Simulator"){
Ti.API.info("ANDROID VERSION:"+Ti.Platform.version);
if(Alloy.Globals.versionCompare(Ti.Platform.version, "6.0") == -1){
getCurrentPosition();
} else
{
if(hasLocationPermissions == true){
getCurrentPosition();
} else {
var win = Alloy.createController('locationPermission', {callback: function(e){
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
if (e.success) {
getCurrentPosition();
} else {
Alloy.Globals.createAlertDialog('There seem to be issues with determining your location.\Please enable Location Services in your Settings to use Fluid');
}
});
}}).getView();
win.open();
}
}
} else {
Ti.API.info("LOCATION FOR SIMULATOR SET TO GALVANIZE - 1644 PLATTE DENVER");
Alloy.Globals.currentLocation = {attributes:{coordinates:{"lat": 39.757885, "lng": -105.0082375}}};//Galvanize
if(successCallback) successCallback();
}
有人解决了吗?我在 5.2.0 GA
根据我的经验android 6 之前的版本,或 23 以下的 SDK 版本,在安装时继续询问所有权限。因此,只有 android 6 及更高版本或 SDK 23 及更高版本才需要使用此功能时的新权限请求。当说请求位置时,我的 5.3GA 应用程序请求棉花糖的权限,但版本 <6 的手机像往常一样在安装时请求权限。我的代码没有任何基于 android 版本的条件逻辑。