如何在Android Pie 9.0中获取传入的电话号码

时间:2019-07-27 09:56:27

标签: android broadcastreceiver android-9.0-pie calllog

在我的应用程序中,呼叫结束后,每个来电号码都会检测到并保存在应用程序中。 一切正常,直到Android Oreo。但是传入的数字在android Pie中始终为null。为什么Pie中的电话号码为空?断开通话后,如何在Android Pie中获取来电号码。

清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ttff.phonemanager">

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/calllogo"
    android:label="@string/app_name"
    android:roundIcon="@drawable/calllogo"
    android:supportsRtl="true"
    android:usesCleartextTraffic="true"
    android:theme="@style/AppTheme">
    <activity android:name="com.ttff.phonemanager.activities.IgnoredNumbersActivity"/>
    <activity android:name="com.ttff.phonemanager.activities.IContactsActivity" />
    <activity android:name="com.ttff.phonemanager.activities.SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.ttff.phonemanager.activities.CategoryPhoneActivity" />
    <activity
        android:name="com.ttff.phonemanager.activities.LogsActivity"
        android:label="@string/title_activity_logs"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name="com.ttff.phonemanager.activities.CategoryActivity"
        android:label="@string/title_activity_category"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity android:name="com.ttff.phonemanager.MainActivity" />

    <receiver
        android:name="com.ttff.phonemanager.callhelpers.CallReciever"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </receiver>

    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths" />
    </provider>

</application>

0 个答案:

没有答案