android.permission.BLUETOOTH 权限
MediaButtonIntentReceiver mMediaButtonReceiver = new MediaButtonIntentReceiver();
IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
mediaFilter.setPriority(MEDIA_BUTTON_INTENT_EMPIRICAL_PRIORITY_VALUE);
registerReceiver(mMediaButtonReceiver, mediaFilter);
不要忘记设置优先权
public class HardButtonReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Log.v(“TestApp”, “Button press received”);
abortBroadcast();
KeyEvent key = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
if(key.getAction() == KeyEvent.ACTION_UP)
{
int keycode = key.getKeyCode();
if(keycode == KeyEvent.KEYCODE_MEDIA_NEXT)
{
Log.d(“TestApp”, “Next Pressed”);
}
else if(keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS)
{
Log.d(“TestApp”, “Previous pressed”);
}
else if(keycode == KeyEvent.KEYCODE_HEADSETHOOK)
{
Log.d(“TestApp”, “Head Set Hook pressed”);
}
}
}
}
因为有些按键不一定被映射却要检查
分享到:
相关推荐
Bluetooth headset profile
本文主要介绍蓝牙协议及其在Headset中的应用
CSR蓝牙立体声耳机源码,做蓝牙耳机很好的参考。
SONY MW1智能无线耳机MP3的配套程序、全套智能扩展程序、中文显示字库、降级包。所有程序2022年5月在华为P20鸿蒙2.0.0系统上,测试正常使用。
XBox360手柄测试工具 XBox Tester (with Headset support) V1.1
csr蓝牙Headset Config Tool-3.0.48中文操作完整详细说明
UDA1341音频接口芯片的驱动源码,可以支持立体声耳机与麦克风
蓝牙耳机原理图BT Headset_Schematic 蓝牙耳机 BT Headset_Schematic.pdf
Headset-SPP-UART
csr 蓝牙3.0 HEADSET 源文件 于ADK2.0下编译包含HST , HFP , USB , A2DP, sd卡
蓝牙耳机编程流程 Headset profile is used to enable wireless connectivity among Bluetooth enabled Headsets, PCs and the cellular phones.
CSR8610耳机系统烧录软件,改软件烧录到外部FLASH,headset_system_CSR8610.psr
蓝牙 stereo_headset实现代码,希望对做蓝牙开发的有帮助
Bluetooth firmware configuration , based on BLuecore4 headset
Headset_Mic_Receiver_Speaker_音频电路分析以及设计.doc
Headset_Mic_Receiver_Speaker_音频电路分析以与设计说明.doc
Supporting profiles: Networking, Dial-up, Fax, LAN access, Headset and WiFi
为世界级的高清语音应用程序,设计Microsemi新的ZL380一系列音频处理器特性公司...当结合Microsemi仅ZL380一系列音频处理器,通过验证解决方案加速客户的上市时间参考设计和易于使用的开发工具,包括MiTuner™GUI软件。
ARINC429总线协议又称ARINC是美国航空电子工程委员会(Airlines Electronic Engineering Committee)于1977年7月提出的,并于同年节月发表并获得批准使用。它的全称是数字式 信息传输系统DITS。协议标准规定了航空电子...
要在任何给定时刻检查耳机,请使用以下方法: JavaScript var headsetDetection = require ( "nativescript-headset-detection" ) ; headsetDetection . isConnected ( ) . then ( function ( connected ) { ...