android - TelephoneManager.getAllCellInfo() 在服务内返回 null
问题描述
如果我试图在没有启动应用程序的情况下在服务中获取 TelephoneManager.getAllCellInfo()(手机启动完成后 - 通过事件启动服务) TelephoneManager.getAllCellInfo() 返回 null。
这是前台服务,它有这个清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.signalsense.signalsense_library">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application>
<service android:name="com.signalsense.signalsense_library.NetworkCollectionService"
android:foregroundServiceType="location"
android:enabled="true"
android:exported="true"/>
</application>
</manifest>
但是,如果我将使用应用程序启动此服务(例如,通过单击应用程序 - 它也会自动启动服务)一切正常。
服务启动代码是平等的。我不明白。也许在没有应用程序的情况下访问 getAllCellInfo() 有一些限制?也许是因为权限“ACCESS_FINE_LOCATION”是危险的,它是为应用程序提供的,并且只适用于应用程序?请帮忙!
解决方案
推荐阅读
- javascript - 提交后盖茨比联系表“挂起”
- javascript - 使用 http GET 请求(Angular 5)使用 Linkedin OAuth 2.0 登录
- vue.js - Vue背景div图像不加载
- java - JPA Query DSL 3.7:在“NOT IN”子句中添加多个列
- javascript - 如何从 PHP 文件调用 HTML 中的警报函数
- python - 尝试在python上按索引合并时出错
- c - C中的逗号和括号以及花括号之间的关系是什么?
- java - 计算机重新启动后Spring无法连接到mysql数据库如何诊断问题所在
- amazon-s3 - 我一直在尝试在 AWS S3 存储桶上上传 ads.txt,但无法上传。有什么建议吗?
- c# - 如何从 C# P/Invoke 中的 void 指针指针获取结果