捕获Intent.ACTION_MEDIA_BUTTON事件
我正在开发一个 Android 音频应用程序。现在,我正在捕捉 并成功播放音频,我想添加一个新功能,通过蓝牙耳机捕获和播放。
我一直在阅读有关内容,似乎我必须管理 ACTION_MEDIA_BUTTON 事件:
Java文件:
....
public class audioBroadcastReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()))
{
Log.d("","@@@@ WORKS" );
}
else
{
Log.d("","@@@@ ????" );
}
....
xml文件
....
<receiver android:name="audioBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON">
</action>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.BLUETOOTH" />
但是什么也没发生,所以,有人可能会给我一个例子或想法:
1°知道蓝牙何时连接。
2° 通过蓝牙耳机路由音频数据包。
谢谢!
I'm developing a Android audio application. Now, I'm capturing
and playing audio with sucess and I want to add a new feature, the capture and playing through bluetooh headset.
I have been reading about that, and seems that I must manage the ACTION_MEDIA_BUTTON
event:
Java file:
....
public class audioBroadcastReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()))
{
Log.d("","@@@@ WORKS" );
}
else
{
Log.d("","@@@@ ????" );
}
....
xml file
....
<receiver android:name="audioBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON">
</action>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.BLUETOOTH" />
But nothing happens, so, somebody may give me a example or a idea for:
1º Know when the bluetooh has been connected.
2º Routed the audio packets through bluetooh headset.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要 bluetoothAdapter 方法。
蓝牙适配器 blueT = 蓝牙适配器.getDefaultAdapter();
You need the bluetoothAdapter method.
BluetoothAdapter blueT = BluetoothAdapter.getDefaulAdapter();