本文整理汇总了Java中android.bluetooth.BluetoothA2dp类的典型用法代码示例。如果您正苦于以下问题:Java BluetoothA2dp类的具体用法?Java BluetoothA2dp怎么用?Java BluetoothA2dp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BluetoothA2dp类属于android.bluetooth包,在下文中一共展示了BluetoothA2dp类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: btA2dpConnect
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
@RpcMinSdk(Build.VERSION_CODES.KITKAT)
@Rpc(
description =
"Connects to a paired or discovered device with A2DP profile."
+ "If a device has been discovered but not paired, this will pair it."
)
public void btA2dpConnect(String deviceAddress) throws Throwable {
BluetoothDevice device = BluetoothAdapterSnippet.getKnownDeviceByAddress(deviceAddress);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
mContext.registerReceiver(new PairingBroadcastReceiver(mContext), filter);
Utils.invokeByReflection(sA2dpProfile, "connect", device);
if (!Utils.waitUntil(
() -> sA2dpProfile.getConnectionState(device) == BluetoothA2dp.STATE_CONNECTED,
120)) {
throw new BluetoothA2dpSnippetException(
"Failed to connect to device "
+ device.getName()
+ "|"
+ device.getAddress()
+ " with A2DP profile within 2min.");
}
}
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:24,代码来源:BluetoothA2dpSnippet.java
示例2: handleBtConnectState
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
/**
* handle FM over BT connect state
*
* @param connectState
* FM over BT connect state
*/
private void handleBtConnectState(int connectState) {
if (!mIsPowerUp) {
return;
}
switch (connectState) {
case BluetoothA2dp.STATE_CONNECTED:
//case BluetoothA2dp.STATE_PLAYING:
//case BluetoothA2dp.STATE_CONNECTING:
Log.d(TAG, "handleBtConnectState bt connected");
changeToEarphoneMode();
break;
case BluetoothA2dp.STATE_DISCONNECTED:
//case BluetoothA2dp.STATE_DISCONNECTING:
Log.d(TAG, "handleBtConnectState bt disconnected");
changeToEarphoneMode();
break;
default:
Log.d(TAG, "invalid fm over bt connect state");
break;
}
}
开发者ID:hyperion70,项目名称:android_device_MTS_x2605,代码行数:31,代码来源:FmRadioService.java
示例3: registerFmBroadcastReceiver
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
private void registerFmBroadcastReceiver() {
IntentFilter filter = new IntentFilter();
filter.addAction(SOUND_POWER_DOWN_MSG);
filter.addAction(Intent.ACTION_SHUTDOWN);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_HEADSET_PLUG);
/* Vanzo:tanglei on: Fri, 13 Mar 2015 21:22:01 +0800
*/
//if (FeatureOption.VANZO_FEATURE_EARPHONE_KEY_ACTION) {
// filter.addAction("com.mediatek.FMRadio.FMRadioService.NEXT_STATION");
//}
// End of Vanzo:tanglei
filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
filter.addAction(ACTION_TOFMSERVICE_POWERDOWN);
filter.addAction(ACTION_FROMATVSERVICE_POWERUP);
mBroadcastReceiver = new FmServiceBroadcastReceiver();
Log.i(TAG, "Register broadcast receiver.");
registerReceiver(mBroadcastReceiver, filter);
}
开发者ID:hyperion70,项目名称:android_device_MTS_x2605,代码行数:21,代码来源:FmRadioService.java
示例4: onServiceConnected
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
Log.e("blueHeadsetListener", "onServiceConnected:" + profile);
if (profile == BluetoothProfile.A2DP) {
voiceMediator.setBluetoothA2dp((BluetoothA2dp) proxy);
} else if (profile == BluetoothProfile.HEADSET) {
voiceMediator.setBluetoothHeadset((BluetoothHeadset) proxy);
}
}
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:10,代码来源:AssistantService.java
示例5: btA2dpDisconnect
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Rpc(description = "Disconnects a device from A2DP profile.")
public void btA2dpDisconnect(String deviceAddress) throws Throwable {
BluetoothDevice device = getConnectedBluetoothDevice(deviceAddress);
Utils.invokeByReflection(sA2dpProfile, "disconnect", device);
if (!Utils.waitUntil(
() -> sA2dpProfile.getConnectionState(device) == BluetoothA2dp.STATE_DISCONNECTED,
120)) {
throw new BluetoothA2dpSnippetException(
"Failed to disconnect device "
+ device.getName()
+ "|"
+ device.getAddress()
+ " from A2DP profile within 2min.");
}
}
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:16,代码来源:BluetoothA2dpSnippet.java
示例6: onServiceConnected
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
try {
if (profile == BluetoothProfile.HEADSET) {
// bh = (BluetoothHeadset) proxy;
// if (bh.getConnectionState(mTouchObject.bluetoothDevice) != BluetoothProfile.STATE_CONNECTED){
// bh.getClass()
// .getMethod("connect", BluetoothDevice.class)
// .invoke(bh, mTouchObject.bluetoothDevice);
// }
} else if (profile == BluetoothProfile.A2DP) {
/**使用A2DP的协议连接蓝牙设备(使用了反射技术调用连接的方法)*/
a2dp = (BluetoothA2dp) proxy;
if (a2dp.getConnectionState(currentBluetoothDevice) != BluetoothProfile.STATE_CONNECTED) {
a2dp.getClass()
.getMethod("connect", BluetoothDevice.class)
.invoke(a2dp, currentBluetoothDevice);
Toast.makeText(MainActivity.this,"请播放音乐",Toast.LENGTH_SHORT).show();
getBondedDevices();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:LiuJunb,项目名称:BlueToothEatPhone,代码行数:28,代码来源:MainActivity.java
示例7: getConnectMethod
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
/**
* Wrapper around some reflection code to get the hidden 'connect()' method
* @return the connect(BluetoothDevice) method, or null if it could not be found
*/
private Method getConnectMethod () {
try {
return BluetoothA2dp.class.getDeclaredMethod("connect", BluetoothDevice.class);
} catch (NoSuchMethodException ex) {
Log.e(TAG, "Unable to find connect(BluetoothDevice) method in BluetoothA2dp proxy.");
return null;
}
}
开发者ID:kcoppock,项目名称:bluetooth-a2dp,代码行数:13,代码来源:BluetoothActivity.java
示例8: setBluetoothA2dp
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
public void setBluetoothA2dp(BluetoothA2dp bluetoothA2dp) {
this.bluetoothA2dp = bluetoothA2dp;
}
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:4,代码来源:VoiceMediator.java
示例9: getBluetoothA2dp
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Override
public BluetoothA2dp getBluetoothA2dp() {
return bluetoothA2dp;
}
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:5,代码来源:VoiceMediator.java
示例10: onServiceConnected
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
public void onServiceConnected(int var1, BluetoothProfile profile) {
sA2dpProfile = (BluetoothA2dp) profile;
sIsA2dpProfileReady = true;
}
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:5,代码来源:BluetoothA2dpSnippet.java
示例11: onServiceConnected
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Override
public void onServiceConnected(int i, BluetoothProfile bluetoothProfile) {
bluetoothHandler
.obtainMessage(BluetoothHandler.MESSAGE_A2DP_PROXY_RECEIVED,(BluetoothA2dp) bluetoothProfile)
.sendToTarget();
}
开发者ID:DeveloperPaul123,项目名称:SimpleBluetoothLibrary,代码行数:7,代码来源:BluetoothUtility.java
示例12: handleMessage
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Override
public void handleMessage(Message message) {
switch (message.what) {
case MESSAGE_READ:
byte[] readBuf = (byte[]) message.obj;
//get how many bytes were actually read.
int datalength = message.arg1;
String readMessage = new String(readBuf, 0, datalength);
if(readBuf.length > 0) {
if(mListener != null)
mListener.onBluetoothDataReceived(readBuf, readMessage);
}
break;
case MESSAGE_WAIT_FOR_CONNECTION:
if(dialog != null) {
dialog.setTitle("");
dialog.setMessage("Waiting...");
dialog.show();
}
break;
case MESSAGE_CONNECTION_MADE:
if(dialog != null) {
if(dialog.isShowing()) {
dialog.dismiss();
if(shouldShowSnackbars && mActivity != null) {
Snackbar.make(mActivity.findViewById(android.R.id.content), "Device connected.",
Snackbar.LENGTH_SHORT).show();
}
}
}
break;
case MESSAGE_A2DP_PROXY_RECEIVED:
BluetoothA2dp device = (BluetoothA2dp) message.obj;
if(device != null && mListener != null) {
mListener.onBluetoothA2DPRequested(device);
}
break;
default:
break;
}
}
开发者ID:DeveloperPaul123,项目名称:SimpleBluetoothLibrary,代码行数:42,代码来源:DefaultBluetoothHandler.java
示例13: onServiceConnected
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
@Override
public void onServiceConnected(int i, BluetoothProfile bluetoothProfile) {
if (mCallback != null) {
mCallback.onA2DPProxyReceived((BluetoothA2dp) bluetoothProfile);
}
}
开发者ID:kcoppock,项目名称:bluetooth-a2dp,代码行数:7,代码来源:BluetoothA2DPRequester.java
示例14: getBluetoothA2dp
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
/**
* 获取可操控蓝牙设备对象
**/
BluetoothA2dp getBluetoothA2dp();
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:5,代码来源:SystemVoiceMediator.java
示例15: onBluetoothA2DPRequested
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
/**
* Called when a request is made to connect to an A2dp device.
* @param bluetoothA2dp the a2dp device.
*/
public void onBluetoothA2DPRequested(BluetoothA2dp bluetoothA2dp) {
}
开发者ID:DeveloperPaul123,项目名称:SimpleBluetoothLibrary,代码行数:8,代码来源:SimpleBluetoothListener.java
示例16: onA2DPProxyReceived
import android.bluetooth.BluetoothA2dp; //导入依赖的package包/类
public void onA2DPProxyReceived (BluetoothA2dp proxy);
开发者ID:kcoppock,项目名称:bluetooth-a2dp,代码行数:2,代码来源:BluetoothA2DPRequester.java
注:本文中的android.bluetooth.BluetoothA2dp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论