androidthings / sample-bluetooth-audio Goto Github PK
View Code? Open in Web Editor NEWBluetooth A2DP sample using Android Things
License: Apache License 2.0
Bluetooth A2DP sample using Android Things
License: Apache License 2.0
From what I understand this sample allow you to transform an Android Things device into a BT speaker, would be nice to support microphone also to allow voice command, with this android things devices can be used as phone headset like in cars or deported voice assistant
I tested the sample on my Android Things with an Android device paired and then played some audio which resulted playback in lag.
Hi,
audio playback seem not works on rpi3 developer 0.7.
Hello I don't hear any audio audio output on that board what shall I do ? No HDMI or display is attached
I used this demo. But when androidthings plays audio, it's very unclear. I don't know why.
I have some old phones with android. I want use it as bluetooth sink.
Can i use sample-bluetooth-audio with old phones to listen music via bluetooth?
Will there be an example for audio source i.e. audio playback via Bluetooth speakers?
Hello,
I got this error when application launch.
Caused by: java.lang.RuntimeException: Stub!
at com.google.android.things.bluetooth.BluetoothProfileManager.(BluetoothProfileManager.java:20)
at com.example.androidthings.bluetooth.audio.A2dpSinkActivity.setupBTProfiles(A2dpSinkActivity.java:224)
at com.example.androidthings.bluetooth.audio.A2dpSinkActivity.initA2DPSink(A2dpSinkActivity.java:246)
at com.example.androidthings.bluetooth.audio.A2dpSinkActivity.onCreate(A2dpSinkActivity.java:170)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Hi,
It has a problem with the example and not runing:
FATAL EXCEPTION: main
Process: com.example.androidthings.bluetooth.audio, PID: 2555
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidthings.bluetooth.audio/com.example.androidthings.bluetooth.audio.A2dpSinkActivity}: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10037 nor current process has android.permission.BLUETOOTH.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
I don't have any issues with this project. It is working completely fine for me. I have some query in this. I
want to show all metadata from AVRCP to my activity.xml file. I want to display artist name, title track and all the other data to my user as I am using this in a car. Additionally, I also wanted to to control my player not only from my phone but from UI as well.
Thank You in advance
Please help!!!
When trying to run on 0.5.1-preview I get the following exception:
com.example.androidthings.bluetooth.audio E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androidthings.bluetooth.audio, PID: 1948
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidthings.bluetooth.audio/com.example.androidthings.bluetooth.audio.A2dpSinkActivity}: java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.MANAGE_INPUT_DRIVERS
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.MANAGE_INPUT_DRIVERS
at android.os.Parcel.readException(Parcel.java:1942)
at android.os.Parcel.readException(Parcel.java:1888)
at com.google.android.things.userdriver.IInputDriverService$Stub$Proxy.createInputDevice(IInputDriverService.java:140)
at com.google.android.things.userdriver.InputDriver.initialize(InputDriver.java:241)
at com.google.android.things.userdriver.InputDriverManager.addInputDriver(InputDriverManager.java:47)
at com.google.android.things.userdriver.UserDriverManager.registerInputDriver(UserDriverManager.java:83)
at com.google.android.things.contrib.driver.button.ButtonInputDriver.register(ButtonInputDriver.java:83)
at com.example.androidthings.bluetooth.audio.A2dpSinkActivity.configureButton(A2dpSinkActivity.java:311)
at com.example.androidthings.bluetooth.audio.A2dpSinkActivity.initA2DPSink(A2dpSinkActivity.java:247)
at com.example.androidthings.bluetooth.audio.A2dpSinkActivity.onCreate(A2dpSinkActivity.java:173)
So it needs me to request the MANAGE_INPUT_DRIVERS permission. And if I do that:
ActivityCompat.requestPermissions(this, new String[]{"com.google.android.things.permission.MANAGE_INPUT_DRIVERS"}, 0);
Then the UI displays an "Allow ... to perform" dialog. But if my IoT device doesn't have screen and input then you can't click the allow button.
After start of play in few minutes the connection is broken with this log message:
beginning of crash 05-16 21:19:30.972 676-701/com.android.bluetooth A/libc: system/bt/hci/src/buffer_allocator.c:25: buffer_alloc: assertion "size <= BT_DEFAULT_BUFFER_SIZE" failed 05-16 21:19:30.973 676-701/com.android.bluetooth A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 701 (bluetooth wake) [ 05-16 21:19:30.973 135: 135 W/ ] debuggerd: handling request: pid=676 uid=1002 gid=1002 tid=701 05-16 21:19:31.072 3787-3787/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 05-16 21:19:31.073 3787-3787/? A/DEBUG: Build fingerprint: 'generic/iot_rpi3/rpi3:7.0/NIG86E/3884620:userdebug/test-keys' 05-16 21:19:31.073 3787-3787/? A/DEBUG: Revision: '0' 05-16 21:19:31.073 3787-3787/? A/DEBUG: ABI: 'arm' 05-16 21:19:31.073 3787-3787/? A/DEBUG: pid: 676, tid: 701, name: bluetooth wake >>> com.android.bluetooth <<< 05-16 21:19:31.073 3787-3787/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 05-16 21:19:31.086 3787-3787/? A/DEBUG: Abort message: 'system/bt/hci/src/buffer_allocator.c:25: buffer_alloc: assertion "size <= BT_DEFAULT_BUFFER_SIZE" failed' 05-16 21:19:31.086 3787-3787/? A/DEBUG: r0 00000000 r1 000002bd r2 00000006 r3 00000008 05-16 21:19:31.086 3787-3787/? A/DEBUG: r4 9de7e978 r5 00000006 r6 9de7e920 r7 0000010c 05-16 21:19:31.086 3787-3787/? A/DEBUG: r8 9eb79e18 r9 9eb79e22 sl 9eb79dd8 fp 9eb79e1c 05-16 21:19:31.086 3787-3787/? A/DEBUG: ip 00000000 sp 9de7e3e0 lr b33d832f pc b33dab7c cpsr 20000010 05-16 21:19:31.116 3787-3787/? A/DEBUG: backtrace: 05-16 21:19:31.116 3787-3787/? A/DEBUG: #00 pc 00048b7c /system/lib/libc.so (tgkill+12) 05-16 21:19:31.116 3787-3787/? A/DEBUG: #01 pc 0004632b /system/lib/libc.so (pthread_kill+34) 05-16 21:19:31.116 3787-3787/? A/DEBUG: #02 pc 0001c6d5 /system/lib/libc.so (raise+10) 05-16 21:19:31.117 3787-3787/? A/DEBUG: #03 pc 00018237 /system/lib/libc.so (__libc_android_abort+34) 05-16 21:19:31.117 3787-3787/? A/DEBUG: #04 pc 00017770 /system/lib/libc.so (abort+4) 05-16 21:19:31.117 3787-3787/? A/DEBUG: #05 pc 0001a6ef /system/lib/libc.so (__libc_fatal+22) 05-16 21:19:31.117 3787-3787/? A/DEBUG: #06 pc 0001842f /system/lib/libc.so (__assert2+18) 05-16 21:19:31.117 3787-3787/? A/DEBUG: #07 pc 0007b97d /system/lib/hw/bluetooth.default.so 05-16 21:19:31.117 3787-3787/? A/DEBUG: #08 pc 0007c8e7 /system/lib/hw/bluetooth.default.so 05-16 21:19:31.117 3787-3787/? A/DEBUG: #09 pc 000e2ef1 /system/lib/hw/bluetooth.default.so 05-16 21:19:31.117 3787-3787/? A/DEBUG: #10 pc 000e3cab /system/lib/hw/bluetooth.default.so 05-16 21:19:31.117 3787-3787/? A/DEBUG: #11 pc 00045dfb /system/lib/libc.so (_ZL15__pthread_startPv+22) 05-16 21:19:31.118 3787-3787/? A/DEBUG: #12 pc 00018c8d /system/lib/libc.so (__start_thread+6)
hi ,thanks for the demo ,recently I'm research a feature about how can use a a2dp sink on Android. so I download the androidthings and this demo project . But it's build smoothly while running crashed with "BluetoothProfileManager.getInstance(); NoSuchMethod", the androidthings is 0.6.1-devpreview android 8.1.0, a raspberry pi version. so I modify by Java reflection to get a BluetoothProfileManager Object, and it running well. then I use another android phone connect to it and play a song, the tone quality is very poor, of course I have try to remove the hdmi. I don't know why the tone quality is so poor, so I ask for a help, good wishes!
Hello, I installed the exmaple on my Android Things device and i can start the application and see the device in my bluetooth list. Pairing is also no problem, but when i want to connect to the device, it disconnects after a few seconds.
I tried it with 3 devices (Android, Iphone and Macbook Pro). Do you know why this is happening?
Thanks in advance!
A minor nitpick: DISCOVERABLE_TIMEOUT_MS
suggests that the time unit is milliseconds. The actual value and its usage is for time measured in seconds, though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.