【问题标题】:OutgoingCallReceiver (out going call) not work on some phone (Samsung, HTC ...)拨出电话接收器(拨出电话)在某些手机(三星、HTC ...)上不起作用
【发布时间】:2015-07-09 15:48:25
【问题描述】:

我有一个使用 OutgoingCallReceiver 类检测拨出呼叫的应用程序。这适用于所有大部分手机。

但在某些手机上,它没有到达 OutgoingCallReceiver 类的函数onReceive()。所以我的应用程序无法检测到拨出电话。我必须重置为出厂配置才能使其正常工作。

这是我的 AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.*******.android.********"
    android:installLocation="preferExternal"
    android:versionCode="28"
    android:versionName="4.2" >

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.WRITE_LOGS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="21"/>        
    <uses-feature
        android:name="android.hardware.telephony"
        android:required="true" /> 
    <uses-feature
        android:name="android.hardware.wifi"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="true" />
    <uses-feature android:name="android.hardware.camera" /> 


    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name=".********"
            android:screenOrientation="portrait" >
            <intent-filter android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.********.android.********.********"
            android:excludeFromRecents="true"
            android:launchMode="singleTop"
            android:screenOrientation="portrait" > <!-- android:theme="@android:style/Theme.Dialog"> -->

            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:excludeFromRecents="true"
            android:screenOrientation="portrait" > 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:excludeFromRecents="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            android:theme="@style/AcceptCallInvisible" >
        </activity>

        <activity
            android:name=".********"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".********"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.SENDTO" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="sms" />
                <data android:scheme="smsto" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.********.********.********.********.********"
            android:launchMode="singleTask"
            android:screenOrientation="portrait" > <!-- android:launchMode="singleTop" -->
            <intent-filter>
                <action android:name="android.intent.action.CALL" />
                <category android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>


        <service android:name=".********" />


        <receiver android:name=".OutgoingCallReceiver" android:exported="true" android:enabled="true">
             <intent-filter android:priority="0" >
                <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
                 <meta-data />
            </intent-filter>
        </receiver>
        <receiver android:name=".SmsReceiver" >
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>
        <receiver
            android:name=".PhoneStateReceiver"
            android:exported="true" android:enabled="true">
             <intent-filter android:priority="0">
                <action android:name="android.intent.action.PHONE_STATE" />
            </intent-filter>
        </receiver>

    </application>
</manifest>

【问题讨论】:

    标签: android broadcastreceiver phone-call


    【解决方案1】:

    可能有其他应用程序正在使用此事件。尝试将接收者的优先级设置为最大整数值..

     <receiver android:name=".OutgoingCallReceiver" android:exported="true" android:enabled="true">
                 <intent-filter android:priority="100000" >
                    <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
                     <meta-data />
                </intent-filter>
            </receiver>
    

    有关正确实施它的更多信息-请参阅http://android-developers.blogspot.com/2013/05/handling-phone-call-requests-right-way.html

    您也可以尝试更改清单条目。在某些 OEM 上可能会出现解析错误。

    像这样:

    <uses-permission />
    ...
    <receiver>
        <intent-filter> . . . </intent-filter>
        <meta-data />
    </receiver>
    

    【讨论】:

    • 您好,感谢您的回答。我已经听从了您的建议,现在我正在等待我们的客户反馈。关于某些 OEM 上的解析错误,我不这么认为,因为我有两个客户使用相同的手机,相同的操作系统(Samsung Galaxy Alpha),我的应用程序在一部手机上工作,但在另一部手机上不工作。我不知道什么样的流行应用程序可能会消耗这个事件。你有什么想法吗?
    • @KhacQuyetDang 客户如何测试应用程序..他们是否正在从应用程序管理器强制停止..如果他们是强制停止接收器将无法工作..
    • @jupesh jain:我还在等待他们的反馈。
    • @jupesh jain:它不适用于客户。我认为这可能是由 conflit 中的某些应用程序引起的,但我不知道是哪个应用程序。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多