如何编写一个程序,使用pre 3.0的Andr​​oid连接到一个A2DP蓝牙设备? [英] How write a program to connect to a a2dp bluetooth device using pre 3.0 Android?

查看:113
本文介绍了如何编写一个程序,使用pre 3.0的Andr​​oid连接到一个A2DP蓝牙设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要连接到了蓝牙A2DP设备,我想能够查询可见的蓝牙设备,然后选择一个支持A2DP的设备,并将它通过A2DP连接,使音频开始通过打连接设备,但我的手机运行姜饼(2.3.3)。

My application needs to connect to a a2dp device over bluetooth and I want to "be able to query for the visible bluetooth devices, then, select a a2dp device and have it 'connect via a2dp' so that audio starts playing through the connected device" but my phone is running gingerbread (2.3.3).

我通过基本蓝牙教程在 http://developer.android去了。 COM /引导/主题/无线/ bluetooth.html ,并得到了我需要连接到蓝牙设备中的一部分,然后我读了页面底部的:

I went through the basic bluetooth tutorial at http://developer.android.com/guide/topics/wireless/bluetooth.html and got to the part I need to connect to the bluetooth device and then I read the bottom of the page:

在开始的Andr​​oid 3.0,蓝牙API包括支持蓝牙配置文件工作的支持。 - >这是否意味着我S.O.L.?有没有办法以编程方式(为什么编程为被拼错了?确实计算器标记)连接到使用pre-3.0版本的Andr​​oid的A2DP设备?是我唯一的选择,以引导用户进入自己的设置/拉起设置编程?因为我能够通过设置来做到这一点,我想我只是认为这是可能的,通过我的应用程序也是如此。

"Starting in Android 3.0, the Bluetooth API includes support for working with Bluetooth profiles." -> does this mean that I am S.O.L.? Is there any way to programmatically (why does stackoverflow mark programmatically as being misspelled?!) connect to a a2dp device using a pre-3.0 version of Android? Is my only option to direct the user to go into their settings/pull up the settings programmatically?? Because I'm able to do it through the settings, I guess I just assumed it would be possible via my application as well.

帮助?

推荐答案

有的蓝牙类(轮廓像BluetoothA2dp)隐藏在姜饼的。这意味着它们的声明由@hide注解,并且它们不包括在SDK(的android.jar)。这是有意进行,因为这些API有可能在较新的版本的Andr​​oid被改变。一般来说是不使用隐藏的API,因为你的应用程序可以停止工作,在较新的Andr​​oid版本是一个好主意,但如果你确定要,遵循 的http://devmaze.word$p$pss.com/2011/01/18/using-com-android-internal-part-1-introduction/

Some of the Bluetooth classes (profiles like BluetoothA2dp) are hidden in Gingerbread. It means that their declaration is is annotated by @hide, and they are not included into the SDK (Android.jar). This is done intentionally, since these APIs are likely to be changed in newer Android versions. Generally it is not a good idea to use hidden APIs, since your App can stop working on newer Android versions, but if you are sure you want to, follow http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/

一旦你对它们的访问做类似(只是一个提示):

Once you get access to them do something like (just a hint):

BluetoothA2dp mBluetoothA2dp = new BluetoothA2dp(context);
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().
// Loop through paired devices
for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) {
    if (device.getName().contains("whatyouwant")) {
        mBluetoothA2dp.addSink(device);
    }
}

这篇关于如何编写一个程序,使用pre 3.0的Andr​​oid连接到一个A2DP蓝牙设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆