android-bluetooth

How to check at one phone whether the other phone is getting an incoming call?

Deadly 提交于 2019-12-11 20:56:07
问题 I have two phones which are paired and connected via bluetooth. How to programmatically check at one phone's end whether the other phone is getting an incoming call? Should I use a particular profile for this, that is, PBAP or HFP? If yes, how I am to do this? Once I detect this, if I want to receive the incoming call via the connected phone, how should I implement that? 回答1: Download Hands Free Profile pdf. It is available easily. It provides you all details about how HFP works and AT

Why BluetoothAdapter.startDiscovery(..) require to get Bluetooth device broadcast?

半腔热情 提交于 2019-12-11 19:45:07
问题 Normally how Android Broadcast work is: app have to create BroadcastReceiver and have to register action intent for it want to get receive event. But in case of Bluetooth device discovery/scanning why it required request call through BluetoothAdapter.startDsiccovery() . Basically I want to dicover BLE device through long live Service running in Background. Any one have idea here? 回答1: private void listenPairedDevice() { Button listenBtn = (Button)findViewById(R.id.button_listen); listenBtn

Reading values from TI BLE CC2540 on android fails with status = 10 [duplicate]

旧城冷巷雨未停 提交于 2019-12-11 14:45:32
问题 This question already exists : Bluetooth BLE service returns status = 10 at onCharacteristicRead Closed 5 years ago . I have a device with CC2540 chip that I try to connect and read / write data from Android. The device is discovered, I am able to connect, but when I try to send read command I get status = 10 at: public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) I used "BLE sensor tag" source code and changed UUIDs according to mine -

Android Bluetooh Socket IOException: 'read failed, socket might be closed or timeout'

不问归期 提交于 2019-12-11 12:58:28
问题 I have a Bluetooth remote control (I think from a selfie stick) connected with my phone via bluetooth. It works, it can take pictures but I want to receive signals from the remote control in my application to remotely control music. The Problem: after I created the socket I cant connect to it without IOException. Here is all the code: public class MainActivity extends Activity { BluetoothAdapter btAdapter; public static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000

Android Bluetooth LE Chat example

自古美人都是妖i 提交于 2019-12-11 12:52:31
问题 I am trying to read serial data over Bluetooth LE but can't find any code examples for this type of bluetooth and api19. Does any one have an example? 回答1: There is no profile defined for serial data communication over Bluetooth Low Energy till now. For this one can use the Bluetooth classic only. In any case, Android devices can not broadcast for advertising packets. They can only scan the advertising packets. Hence, these devices will be in Central mode only. But can act as either server or

Converting String to char when String is a valid char

こ雲淡風輕ζ 提交于 2019-12-11 10:05:00
问题 I am doing socket communication using bluetooth in which I am getting hex values as a variables in string format. I can write - char char1= 0x7D; But somehow if value 0x7D is string then how to convert that to char. For example, I can't do - String string1 = "0x7D"; char char1 = (char)string1; Any approach to do that ? I want this because I can write to socket with - char[] uploadCommand2 = {0x7d, 0x4d, 0x01, 0x00, 0x01, 0xcb}; But can't if 0x7d is a string like -- char[] uploadCommand2 =

How to register broadcast receiver inside instrumentation?

纵饮孤独 提交于 2019-12-11 06:38:26
问题 I am trying to get bluetooth discovery results through an apk which runs as android junit runner. Everything works fine but while registerReciever I get below error. What could be the reason ? java.lang.SecurityException: Given caller package com.ex.test is not running in process ProcessRecord{d740580 19462:com.ex/u0a302} Code- @Test public void demo() throws Exception { Context ctx = InstrumentationRegistry.getInstrumentation().getContext(); BluetoothAdapter mBtAdapter = BluetoothAdapter

Android bluetooth connect two or more devices and send data

蓝咒 提交于 2019-12-11 06:27:51
问题 Hi I need to connect 3 different devices (Clients) to a fourth device (Server). Here is my server code: public class MainServerActivity extends Activity { ArrayAdapter<String> listAdapter; ListView listView; TextView textViewTextoRecibido; BluetoothAdapter btADapter; Set<BluetoothDevice> devicesArray; ArrayList<String> pairedDevices; ArrayList<BluetoothDevice> devices; IntentFilter filter; BroadcastReceiver receiver; public AcceptThread acceptThread; protected static final int SUCCESS_CONNECT

Bluetooth socket not connecting, Unable to pair devices

怎甘沉沦 提交于 2019-12-11 04:29:48
问题 I'm learning android and working on an project's app which uses Bluetooth. I was already able to discover and list devices. But when I try to pair devices, socket.connect() fails everytime. I'm new to java and android. I have tried an insecure connection, default UUID and device's UUID but still got the same result and logs. here is the complete code so far package com.example.bluetoothhc; import android.bluetooth.BluetoothSocket; import android.support.v7.app.AppCompatActivity; import

How to make a VOIP app use a carkit like the native call app?

走远了吗. 提交于 2019-12-11 04:15:48
问题 I've been searching for over a week now with no clear solutions. We are building an ap that can make VOIP calls. The current implementation uses AudioManager.requestAudioFocus to tunnel a voice call over a bluetooth headset or carkit, and can uses the AudioManager state to accept incomming calls or hangup ongoing calls when the accept/hangup button on a headset is pressed. This all works fine. However, when connected with a carkit that has both an accept and hangup button, the current