开发者

I can't seem to catch ACTION_SCO_AUDIO_STATE_CHANGED intent why?

开发者 https://www.devze.com 2023-01-30 14:16 出处:网络
I\'m currently trying to catch states for ACTION_SCO_AUDIO_STATE_CHANGED as specified by: http://developer.android.com/reference/android/media/AudioManager.html#ACTION_SCO_AUDIO_STATE_CHANGED

I'm currently trying to catch states for ACTION_SCO_AUDIO_STATE_CHANGED as specified by: http://developer.android.com/reference/android/media/AudioManager.html#ACTION_SCO_AUDIO_STATE_CHANGED

I have registered the intent on my manifest but I'm not getting anything when connecting to a bluetooth device. Any particular permission I need or something?

Manifest:

    <receiver android:name="com.app.receiver.BluetoothReceiver">
        <intent-filter>
            <action android:name="android.media.SCO_AUDIO_STATE_CHANGED" />
            <action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
            <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
            <action android:name="android.blueto开发者_开发知识库oth.device.action.ACL_DISCONNECT_REQUESTED" />  
            <action android:name="android.bluetooth.device.action.BOND_STATE_CHANGED" />
        </intent-filter>
    </receiver>

I can't get any of the calls from BOND_STATE_CHANGED, SCO_AUDIO_STATE_CHANGED or ACL_DISCONNECT_REQUESTED. The other intents I'm receiving them just fine.

Thanks,

-Jona


It's probably a broadcast intent that cannot be received using the Manifest. You'll have to setup a BroadcastReceiver object and register it to receive the broadcast. The Receiver must be active in order to receive the intent.

Some broadcasts intents work like this while others are allowed to be caught via the manifest.

The other possibility is that the receiver requires a permission that you aren't requesting.

This is an important note from the SDK about Context.registerReceiver(). Note: this method cannot be called from a BroadcastReceiver component; that is, from a BroadcastReceiver that is declared in an application's manifest. It is okay, however, to call this method from another BroadcastReceiver that has itself been registered at run time with registerReceiver(BroadcastReceiver, IntentFilter), since the lifetime of such a registered BroadcastReceiver is tied to the object that registered it


   <uses-permission android:name="android.permission.BROADCAST_STICKY" 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号