android-bluetooth

how to read from the InputStream of a bluetooth on Android

前提是你 提交于 2019-12-13 02:23:42
问题 I am trying to test this bluetooth communication example between a PC and an Android phone. My SPP client is exactly the one from there and it works fine. I am new to Android and I didn't want to make it run in a separate thread because I don't know how, so I just did everything in the onCreate() method. If this is not the best way, feel free to point me to a better way, but this is not my main problem. The problem is I wanted to display the text received via bluetooth on a textView and I don

How to connect the Bluetooth device by click the item of listview in Android?

徘徊边缘 提交于 2019-12-12 21:14:37
问题 I am developing an application where I have to connect to Bluetooth device on Android 4.3. I can scan the bluetooth device, but it can not connect the bluetooth device. I have already add the permission in Manifest of the following: <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH" /> My Operation is when I push SCAN Button, it will scan the Bluetooth device and show on the ListView. When I click the bluetooth

BluetoothLeAdvertiser AdvertiseCallback throws ADVERTISE_FAILED_TOO_MANY_ADVERTISERS

好久不见. 提交于 2019-12-12 18:35:52
问题 I have this code to create an Advertise: private void startLeAdvertise() { AdvertiseSettings settings = new AdvertiseSettings.Builder() .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY) .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH) .setConnectable(true) .setTimeout(ADVERTISE_TIMEOUT) .build(); AdvertiseData data = new AdvertiseData.Builder() .addServiceUuid(new ParcelUuid(UUID.fromString(BEACON_SERVICE))) .build(); mAdvertiseCallback = new AdvertiseCallback() {

How do I effectively read temperature from two BLE devices at the same time?

萝らか妹 提交于 2019-12-12 16:38:04
问题 First of all, I am using RxAndroidBLE library to manage my BLE connections. I have two SensorTag devices and I want to read temperature from both at the same time. For example, I'd like to read the temperature from both devices exactly every 500ms and display it to user in two TextViews. My app currently successfully connects to both BLE devices like this: @OnClick(R.id.connectButton1) public void connectFirstSensorTag(Button b) { if (!isDeviceConnected(sensorTag1)) { connectionObservable1 =

Secure.getString(mContext.getContentResolver(), “bluetooth_address”) return null in Android O

谁都会走 提交于 2019-12-12 10:45:24
问题 When I'm trying to get Blutooth Address on Android O device by this way: private String getBlutoothAddress(Context mContext){ // Check version API Android BluetoothAdapter myBluetoothAdapter; String macAddress; int currentApiVersion = android.os.Build.VERSION.SDK_INT; if (currentApiVersion >= android.os.Build.VERSION_CODES.M) { macAddress = Settings.Secure.getString(mContext.getContentResolver(), "bluetooth_address"); } else { // Do this for phones running an SDK before lollipop macAddress =

iBeacon Ranging Service Not Returning any Beacons (Part 2)

倾然丶 夕夏残阳落幕 提交于 2019-12-12 06:35:57
问题 My code has now reached checkpoint 1 and 2. However, it is only detecting the beacon once. I want it to keep receiving the location of the beacon (distance) every five seconds. How can I implement this? Thanks again public class RangingService extends Service implements BeaconConsumer { private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this); Handler handler; String b = ""; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onStart

Video Streaming over wifi?

社会主义新天地 提交于 2019-12-12 03:08:43
问题 How do I stream a video from my android smartphone to my Laptop(windows 7) without using any app? Any suggestions? A brief explanation would really help. And, I mean "streaming" and not file transfer. 回答1: You cannot use this feature without using any app,what you need to do is to program a socket client that sends the video to the server which is connected over wifi .try googling about TCP sockets in android 回答2: Go to the following link . https://code.google.com/p/spydroid-ipcamera/ you

Android BLE Notification

馋奶兔 提交于 2019-12-12 02:24:56
问题 I'm developing an android application using BLE. I've implemented all the basic operations like discovery, connection, and data transfer. Now I was looking for BLE notifications, Is it possible to receive notification from BLE device when the application is not running (not even in background). What I want to implement is the notification similar to GCM/FCM, we receive notifications in our app even though app is not running. So want to check if similar notification mechanism is supported by

Bundling inputStream.read messages

浪尽此生 提交于 2019-12-12 02:00:05
问题 I am using the Android Bluetooth Chat sample code to chat (send commands + receive responses) with a bluetooth device. It is working fine when I send a command, and I receive a response from the device that is passed to message handler. The issue I am having is the response is cut up into pieces. Example: I send the string "{Lights:ON}\n" and my activity correctly displays Me: {Lights:ON} . The device lights turn on and it returns it's response "{FLash_Lights:ON}\n" . However my activity

startLeScan returns false

醉酒当歌 提交于 2019-12-12 01:28:29
问题 BluetoothAdapter's method startLeScan returns false sometimes during scanning BLE devices.Hence,I am facing issues in my application.I am using the newer method startScan(ScanCallback callback) from Lollipop onwards but needs to support API level 18 and above.Any help is appreciated. 回答1: If you look at the source code for startLeScan here, you will see that there are several things that can cause the return code to be false: A null callback ha been provided A scan has already been started by