android-bluetooth

Obtaining a List of Available Bluetooth Devices on Android

徘徊边缘 提交于 2019-12-02 02:20:43
In this question , @nhoxbypass provides this method for the purpose of adding found Bluetooth devices to a list: private BroadcastReceiver myReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Message msg = Message.obtain(); String action = intent.getAction(); if(BluetoothDevice.ACTION_FOUND.equals(action)){ //Found, add to a device list } } }; However, I do not understand how a reference to the found device can be obtained, how can this be done? I do not have permission to comment on the original question, so I have chosen to extend it here.

Bluetooth LE advertising fails when started and stopped cyclically

荒凉一梦 提交于 2019-12-01 14:49:23
问题 I've tried out Bluetooth LE advertising i.e. using an Android phone as a BLE "peripheral" device. Starting and stopping a constant advertising once works fine but if I'd like to actually transmit some varying data I would need to start, stop and restart the advertising in a cycle and always change the advertising package. I'm using these methods of course: BluetoothLeAdvertiser.startAdvertising() BluetoothLeAdvertiser.stopAdvertising() At least on a Motorola Moto G 4G 2nd gen. (XT1072) with

Android Studio, Bluetooth configuration issue

别来无恙 提交于 2019-12-01 14:45:00
So im a newbie in android still, but ive been working on an app that basically i want it to communicate with an arduino through bluetooth, but the point here is that when im trying to configure the bluetooth code, i get thrown an error in the logcat, which is: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.OutputStream android.bluetooth.BluetoothSocket.getOutputStream()' on a null object reference" , and this has really been giving me problems for a week and i cant find a slution, im sure this is not that complicated for an experienced programmer, so id really

How to Send an Audio HEX file to Ble Device

99封情书 提交于 2019-12-01 13:18:16
I have a working ble device with android . it sends and receives data finely through the Android app. But Now My Problem is I want to send Some Audio HEX files to my BLE Device. And its larger Than 20 bytes. How Can i send such a data to a BLE Device. ?? For send data upper than 20bytes, you need to change the MTU-exchange. To API LEVEL 21, you can use requestMtu ( Android Developer ), it negotiates with the peripherical device and you can define until 512 bytes. The MTU value is defined in peripherical side. Remember the data size that you can send is MTU-3 bytes. For API LEVEL less than 21,

how to send data (a string) to a paired device in android?

江枫思渺然 提交于 2019-12-01 13:17:20
I am working on bluetooth for the first time. I got the list of paired devices. Now my requirement is I need to send some data (a string) to the device. how can I do that? I tried searching but didn't find anything useful. Could anyone help out this? Something like this might suffice: DataOutputStream os; BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter(); BroadcastReceiver discoveryResult = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String remoteDeviceName = intent.getStringExtra(BluetoothDevice.EXTRA_NAME); BluetoothDevice remoteDevice;

Android Studio, Bluetooth configuration issue

时光总嘲笑我的痴心妄想 提交于 2019-12-01 12:16:12
问题 So im a newbie in android still, but ive been working on an app that basically i want it to communicate with an arduino through bluetooth, but the point here is that when im trying to configure the bluetooth code, i get thrown an error in the logcat, which is: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.OutputStream android.bluetooth.BluetoothSocket.getOutputStream()' on a null object reference" , and this has really been giving me problems for a week and i cant

how to send data (a string) to a paired device in android?

左心房为你撑大大i 提交于 2019-12-01 10:11:32
问题 I am working on bluetooth for the first time. I got the list of paired devices. Now my requirement is I need to send some data (a string) to the device. how can I do that? I tried searching but didn't find anything useful. Could anyone help out this? 回答1: Something like this might suffice: DataOutputStream os; BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter(); BroadcastReceiver discoveryResult = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) {

How to determine when a bluetooth file is received?

大城市里の小女人 提交于 2019-12-01 09:50:52
问题 In my app, I need to edit an bluetooth-transferred file just after it is received. Exactly what Intent do I have to listen to with my BroadcastReceiver, in order to find out when a file has been received via Bluetooth? Also, please tell me if there are other solutions. 回答1: If the user gets a file via android OS, it's via the download manager. in that case u should register DownloadManager.ACTION_DOWNLOAD_COMPLETE private void registerBroadcastReceiver() { broadCastReceiver = new

Can an Android 4.4 device act as an iBeacon? [closed]

牧云@^-^@ 提交于 2019-12-01 09:28:10
In an answer to another question , I saw that "You can also transmit as a beacon on rooted Android 4.4.3 devices, but it requires an app installed with system privileges." How can this be done? Yes, this is possible on 4.4.3, but the critical API methods startAdvertising() , stopAdvertising() and getAdvScanData() (which allows you to read and write the raw information sent out in the advertisement) are blocked from use unless an app has android.permission.BLUETOOTH_PRIVILEGED . This is a system-level permission, so the only way to get this is for your custom app is to root your phone, and

Make communication between 2 android phones over BLE

こ雲淡風輕ζ 提交于 2019-12-01 07:36:34
问题 I have two android smartphones (Xperia Z and Xperia Z1) and both have BLE capability. Can I connect to one of them as a peripheral over BLE? In my application I can see and conenct a BLE as peripheral (CC2541 device) and I can see all sevices and characteristics. But same application can not see one of my phones?? Is there a way to achice that?? 回答1: As of Android 4.4 there is no support for peripheral mod in the Android BLE apis. You would need this to be able to make two phones talk over