android-bluetooth

How to send the text data to CC2541 keyfob via Android 4.3?

浪子不回头ぞ 提交于 2019-12-10 11:29:44
问题 I am developing an application where I have to connect to Bluetooth device on Android 4.3. And I want to change the name of CC2541 Keyfob via the Android application. My ideas is: 1.There has a Plain Text that I can type the name what I want in my Android application. 2.After I type the name, I push the button to send this text. 3.If the CC2541 receive this text from Android application , it will change the text in the deviceName[] of the following code in keyfobdemo.c: static uint8

How to differentiate the connected bluetooth device in android programmatically?

丶灬走出姿态 提交于 2019-12-10 02:58:47
问题 Whether it is a bluetooth headset or mobile phones? how to differentiate the bluetooth headset and bluetooth enabled android device in android code. I am developing a small application,in that I have a feature of blocking the data transfer via bluetooth but it need to allow communication via bluetooth headset. I referred the examples and codes in that they suggest me to pair/unpair the bluetooth devices only. Android: How to pair bluetooth devices programmatically? or else get all connected

What is the proper method for reading a GATT characteristic in Android?

天涯浪子 提交于 2019-12-10 01:58:44
问题 In attempting to read the value of a Bluetooth Low-Energy GATT characteristic in the Android API 18, I came across the following dilemma: What is the proper way to retrieve the value stored in a characteristic? And at which level of the stack should this action take place? In conducting my own research, I stumbled upon what I understand are two possible methods: BluetoothGatt .readCharacteristic(BluetoothGattCharacteristic characteristic) BluetoothGattCharacteristic .getValue() public void

Sending File via Bluetooth using Intent Action SEND does not working in android 4.2.2?

两盒软妹~` 提交于 2019-12-10 00:58:24
问题 I have used Intent-SEND to share the files via bluetooth.I have add my code here. Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setComponent(new ComponentName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity")); intent.setType("text/plain"); File file = new File(Environment.getExternalStorageDirectory() .getAbsolutePath() + "/Sample.txt"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); startActivity(intent); This code is

BluetoothLeScanner.startScan with Android 6.0 does not discover devices

旧街凉风 提交于 2019-12-09 07:53:39
问题 I'm trying to use the function BluatoothLeScanner.startScan instead of the deprecated one BluetoothAdapter.startLeScan . Yesterday I updated my Nexus 5 to Android 6.0 and since that moment my app does not work anymore. I firstly add the preferences required ACCESS_COARSE_LOCATION as found here, https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id. Then I added the permission as described here: https://developer.android.com/training/permissions

How to make Bluetooth Undiscoverable?

倖福魔咒の 提交于 2019-12-09 04:32:29
I have learned the codes to make blue-tooth discoverable in Android,like: Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivity(discoverableIntent);` = So, how can i make blue-tooth un-discoverable artificially as soon as i make it discoverable? Thanks for all help! I have found a method,although i don't understand it yet,it works in my project! public void closeDiscoverableTimeout() { BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter(); try { Method

Cannot read characteristic. Android BLE

帅比萌擦擦* 提交于 2019-12-08 20:45:43
问题 I'd like to read the data from a specific characteristic of my remote BLE device to my Android tablet Nexus 7. The problem is that, I can receive the data by enabling the notification of that characteristic even without calling readCharacteristic . But I cannot successfully read characteristic by calling readCharacteristic without enabling the notification. mBluetoothGatt.readCharacteristic(characteristic) returns false. Thus the function onCharacteristicRead has never been triggered. I also

How do you get data from a Bluetooth LE device

て烟熏妆下的殇ゞ 提交于 2019-12-08 15:26:45
问题 I have a bluetooth barcode scanner that supports bluetooth LE and I am trying to get the barcode information from it when one is scanned. I can connect to it fine onServicesDiscovered gets called in my BluetoothGattCallback but I am not sure what to do from there. With a classic bluetooth connection you would get a InputStream from a BluetoothSocket and you would just wait for the read() to give you data but I am not sure how it works with Bluetooth LE. I tried looping through the

Bluetooth Low Energy device scanning Failed with an exception

一笑奈何 提交于 2019-12-08 14:38:09
问题 I am referring to developer docs to scan BLE devices - http://developer.android.com/guide/topics/connectivity/bluetooth-le.html In my activity class LookUpActivity , I called a method findBLE() on a button click- //This will scan BLE devices public void findBLE() { Intent intent = new Intent(LookUpActivity.this, DeviceScanActivity.class); startActivity(intent); } But got the following exception - Could not find class 'com.testapp.main.DeviceScanActivity$1', referenced from method com.testapp

ADB: How to automate complete BT Scan, pair and connect

≯℡__Kan透↙ 提交于 2019-12-08 11:06:41
问题 I am looking for Automating the below activities using ADB. Bluetooth settings -> TunrnOn BT -> Pairing (To a BT mac address which i can set) -> Connect to the BT Device on certain profiles like A2DP/HFP. I have already found here and here how to turn on and set BT to discoverable using ADB. But I am still stuck on how to make a connection request again using ADB. Would there be a way to completely automate these steps. Appreciate your valuable comments. 回答1: There is no solution possible