android-bluetooth

How will i Split a String that received from a ble device for if else checking and display a value on Textview

帅比萌擦擦* 提交于 2019-12-08 10:25:03
问题 In my Android app I receive data from my ble device as something like 10100201201511 ( it includes date,time and other attributes). I hope I received it as a string, I want to check that value and display it on textview. My Requirement is If (position1=0){ //display yes in Text view }else { // display No in Textview } But I always get errors like Array type expected; found 'Java.lang.String' My current code is: @Override public void onCharacteristicRead(BluetoothGatt gatt,

getting STATE_DISCONNECTED while connecting using bluetooth smart

痞子三分冷 提交于 2019-12-08 09:12:51
问题 I am trying to create a advertiser on Android L and my other android device is scanning that device and trying to make a connection with it. but every time i call connectGatt i am getting BluetoothProfile.STATE_DISCONNECTED in gatt callback. this is how i have created the advertisement // advertisement settings AdvertiseSettings.Builder builderSetting= new AdvertiseSettings.Builder(); builderSetting.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED); builderSetting.setConnectable

Connection is not created (failed or aborted) exception thrown during Bluetooth connection in Android

本秂侑毒 提交于 2019-12-08 07:22:45
问题 I am working on a project which makes use of an android tablet(iball 3G 7271) that runs on 4.1.2 and is made of MTK processor AND an RN42 bluetooth (chip on a PCB).These two modules communicate with each other to transfer data among them via bluetooth. I am facing issues.wherein at certain instances I repeatedly get exceptions stating 'Connection is not created (failed or aborted)'.I have found the instances as described below: I copied the relevant code from the BlueTerm app(from playstore)

How to send command to BLE device and show result

◇◆丶佛笑我妖孽 提交于 2019-12-08 07:18:59
问题 @Override public void onServicesDiscovered(final BluetoothGatt gatt, int status) { super.onServicesDiscovered(gatt, status); if (status == BluetoothGatt.GATT_SUCCESS) { List<BluetoothGattCharacteristic> characteristics = null; List<BluetoothGattService> services = gatt.getServices(); //I am getting all services for (final BluetoothGattService service : services) { characteristics = service.getCharacteristics(); //I am getting all characteristics for each services } } } I am able to connect

Reading from a BluetoothGattCharacteristic is failing

允我心安 提交于 2019-12-08 05:57:11
问题 Im trying to read the value stored in a BluetoothGattCharacteristic . The following is my BluetoothGattCallback code, where most of the action takes place: private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { @Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { if (newState == BluetoothProfile.STATE_CONNECTED) { Log.i(TAG, "Connected to GATT server."); Log.i(TAG, "Getting services...."); gatt.discoverServices(); } else if

How to set a2dp sink as a default (android 7.1)

依然范特西╮ 提交于 2019-12-08 05:16:09
问题 We made a custom board which has Android 7.1 operating system as a our custom board must act to a reciver with bluetooth(while a2dp sink profile in bluetooth can do this), but we have do many works over weeks on it , but it still not work, so i'd like to ask somebody who know or had similar expirence on it could help. Android 7.1 used the fluoride Bluetooth stack our works : 1. packages/apps/Bluetooth/res/values/config.xml <bool name="profile_supported_a2dp">true</bool> <bool name="profile

how to wait till bluetooth turn on in android

北慕城南 提交于 2019-12-07 16:25:09
问题 I need to turn on Bluetooth in an android device programmatically and wait till it on to proceed to next line of code. My code is as below if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); ctx.startActivity(enableBtIntent); } When doing like this, the code continue to execute from nect line without waiting for bluetooth completely on. Is there any way to solve this? Can I add a look to check if bluetooth is on? 回答1: You can

Android Ble GATT_ERROR 133 getting often with samsung devices

浪尽此生 提交于 2019-12-07 11:56:46
问题 I am working on BLE Applications, I have tested with different devices like Nexus, Moto, Samsung, LG. I am getting the GATT Error 133 in Samsung Devices alone(Samsung A5 2016). Trying to connect 10 times it gets connected only 2 or 3 times.Please Help me out. 来源: https://stackoverflow.com/questions/40465373/android-ble-gatt-error-133-getting-often-with-samsung-devices

Bluetooth GATT - onServicesDiscovered(BluetoothGatt gatt, int status) does not contain all Services

强颜欢笑 提交于 2019-12-07 10:10:32
问题 I have code that connects to, and then tries to discover all Services provided by a custom BLE server device advertising custom Services. The code works on Nexus 5 with Android 5.1 Samsung SM-T320 with Android 4.4.2 ZTE Blade Vec 4G With Android 4.4.2 Code does not work on Samsung SM-T360 with Android 4.4.4 Samsung GT-I9195 with Android 4.4.2 On devices where it fails it often discovers all of the BLE Services on one (of two) devices that advertises the same BLE Services. Restarting the

In leScanCallback device.getName() returns null on few devices

大憨熊 提交于 2019-12-07 08:29:28
Checked following post but not helpful on my case : BluetoothDevice always returns null on getName() My problem I am developing an application that scans the nearby Bluetooth device and displays in the home screen.But on few devices(i.e moto G,samsung note2) the device name is null on leScanCallback. My code private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { if (device.getName() != null){//<<- Here it null on few device //my process } } }; Note: I