问题描述
我有一个应用程序一直运行到现在。最近升级到 WM 25,目标 SDK 是 29,目前正在使用 Android 11 的 Pixel 3a 上进行测试。该应用程序目前无法访问设备的位置,除非您选择我不想要的“始终允许”。如果您完全关闭应用程序并将应用程序设置中的权限更改为“始终允许”并重新启动应用程序,则选择“在使用应用程序时”最终会导致问题并且应用程序冻结主屏幕上的设备位置。目标是只允许应用程序在使用时访问设备位置,但我阅读的所有内容都没有告诉我出了什么问题?
目前在我的 WLanguage 代码(如下)中使用 GPSFollowMovement、GPS 状态和 GPSInitParameter 函数。
在我的应用清单中还有 ACCESS_COURSE_LOCATION、ACCESS_FINE_LOCATION 和 ACCESS_BACKGROUND_LOCATION 权限。
第一个权限请求读取时似乎没有任何工作
此应用可能希望一直访问您的位置信息,即使您没有使用该应用
- 在使用应用程序时
- 仅此时
- 拒绝
出现第二个窗口,内容为
更改应用的位置访问权限? 此应用希望始终访问您的位置信息,即使您未使用该应用也是如此。
- 保持“应用正在使用中”
PROCEDURE Start_GPS()
GPSInitParameter(gpsAuto,gpsPrecisionHigh)
// Check the GPS
IF GPsstatus() = gpsdisabled THEN
Info("Please enable the GPS in your phone settings.")
ELSE
_ChangeGPsstatus(GPsstatus())
END
// Callback procedure for detecting the change of GPS status
GPsstatus(_ChangeGPsstatus)
PROCEDURE _ChangeGPsstatus(nStatus)
SWITCH nStatus
CASE gpsEnabled // the provider was enabled by the user.
EXPRESS_WIN_MAIN.STC_GPsstatus = "GPS Enabled"
// Asks to follow the move with a maximum time between two calls to
GPSFollowMovement(_GetPosition,1000)
CASE gpsdisabled // the provider was disabled by the user.
EXPRESS_WIN_MAIN.STC_GPsstatus= "GPS disabled"
CASE gpsOffService // the provider is off service.
EXPRESS_WIN_MAIN.STC_GPsstatus = "GPS off service"
CASE gpsUnavailable // the provider is temporarily unavailable.
EXPRESS_WIN_MAIN.STC_GPsstatus = "GPS Unavailable"
CASE gpsAvailable // the provider is available.
EXPRESS_WIN_MAIN.STC_GPsstatus = "GPS Available"
GPSFollowMovement(_GetPosition,1000)
END
PROCEDURE _GetPosition(MyPosition 是一个 geoPosition)
// Update the @R_762_4045@ion about the position
// Latitude and longitude
grCurrentLatitude = MyPosition..Latitude
grCurrentLongitude = MyPosition..Longitude
IF MyPosition..PrecisionValid THEN
grCurrentGPSAccuracy = MyPosition..Precision
ELSE
grCurrentGPSAccuracy = -1.0 //default value for unkNown precision
END
//IF CurrentWin() ~= "EXPRESS_WIN_MAIN" THEN
IF grCurrentLatitude > 0 THEN
EXPRESS_WIN_MAIN.STC_Latitude = NumToString(grCurrentLatitude,"3.4f") + "° (N)"
END
IF grCurrentLongitude < 0 THEN
EXPRESS_WIN_MAIN.STC_Longitude = NumToString(grCurrentLongitude,"+3.4f") + "° (W)"
END
IF grCurrentGPSAccuracy > 0 THEN
EXPRESS_WIN_MAIN.STC_GPSAccuracy = NumToString(grCurrentGPSAccuracy / 0.3048,"+5.1f") + " ft"
ELSE
EXPRESS_WIN_MAIN.STC_GPSAccuracy = "UnkNown"
END
//ELSE
//IF CurrentWin() ~= "EXPRESS_WIN_REPORT" THEN
WHEN EXCEPTION IN
IF grCurrentLatitude > 0 THEN
EXPRESS_WIN_REPORT.STC_Latitude = NumToString(grCurrentLatitude,"3.4f") + "° (N)"
END
IF grCurrentLongitude < 0 THEN
EXPRESS_WIN_REPORT.STC_Longitude = NumToString(grCurrentLongitude,"+3.4f") + "° (W)"
END
IF grCurrentGPSAccuracy > 0 THEN
EXPRESS_WIN_REPORT.STC_GPSAccuracy = NumToString(grCurrentGPSAccuracy / 0.3048,"+5.1f") + " ft"
ELSE
EXPRESS_WIN_REPORT.STC_GPSAccuracy = "UnkNown"
END
DO
//for some reason when closing EXPRESS_WIN_REPORT,after landing in EXPRESS_WIN_DETAILS,still gets through the IF and gives an error
END
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)