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”是危险的,它是为应用程序提供的,只能与应用程序一起使用? 请帮忙!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)