Seems like when made discoverable, an android device (A) doesn't show it's UUIDS, unless the device trying to get it's UUIDS (B) is paired with it.
Any body know how to make it's UUIDS public to any device ? By the way I'm not working with BLE, only Classic Bluetooth
Related
Is it possible to change the BLE Advertisement data while BLE advertisement is going on(with out having to stop and start the advertisement).
Use Case : Reading a value of sensor (Say Accelerometer sensor) and advertising it every 1 second.
Yes, you can do it with the setAdvertisingData method from the AdvertisingSet class. However this class was added in API 26 so for previous versions of Android, you will have to restart the advertising.
In my Android app, in order to determine certain features, I'm checking a device's ISO country code using getSimCountryIso() and getNetworkCountryIso().
Tested this on my real mobile devices and emulators and all returned certain values without any errors.
One of them is my daily driver phone which has a SIM card in it, but the others have no SIM cards. So at first, I thought both getSimCountryIso() and getNetworkCountryIso() always return some values, but now I'm in doubt because all my real devices used to have SIM cards once and emulators may differ from real ones.
I wonder what will happen when those are called on real Tablets which NEVER HAD SIM cards in them and have only WiFi connections. Can I always expect a certain value? Or an exception or null?
I thought you would get a NullPointerException, but having tested it on a tablet - Pixel C, running Nougat - I actually got back empty Strings for both TelephonyManager.getSimCountryIso() and TelephonyManager.getNetworkCountryIso().
I had assumed the result would be an NPE because calling PackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY) on a tablet will return false. That was enough to tell me that you shouldn't be trying to get SIM or network country codes this way on a non-phone device. However, if you try to retrieve the TelephonyManager using Context.getSystemService() on such a device anyway, you still get a non-null TelephonyManager - it just won't be helpful in providing a sim or network country.
In my opinion, if you are dealing with a device that does not have the Telephony system feature, you ought to consider using GPS location, or the user-set locale if you really don't want to encroach on location permissions and can tolerate the user-set locale not being where the user necessarily is.
I am new to using Bluecove API and it seems that after a lot of research, I still cannot find a way to check if a RemoteDevice is already paired to the running machine or not.
First of all, I successfully manage to start a scan however, I find it strange that Bluecove does not offer a way to only look for devices that are in discoverable mode hence the need to check if paired or not ...
To be more precisded I am "translating" a project that I developped in C# using InTheHand.dll for Bluetooth management. This assembly is great and helped me achieved what I wanted to do : scan for devices in discoverable mode and in range, initiate pairing process, handle data via Bluetooth streams.
I need to do the same thing with Bluecove.
Why is it so hard to find answers ? The documentation says almost nothing about pairing although I managed to pair a device I knew was not paired via RemoteDevice.authenticate().
Anyway to summup :
How to start a scan for only devices in discovery mode ?
How to find out whether a device was already paired or not ?
Note :
using both RemoteDevice.isAuthenticated() and RemoteDeviceHelper.implIsAuthenticated(remoteDevice) always return false regardless of the paired status.
Note 2 :
Furthermore, having a lookg at RemoteDeviceHelper.javafrom http://bluecove.googlecode.com/svn/trunk/bluecove/src/main/java/com/intel/bluetooth/RemoteDeviceHelper.java , there is a private property for boolean paired.
It seems no public method will use it ...
Even weirder and desperatly frustating, in the debugger mode, looking at a specific RemoteDevice, I can see the value of this property. It is indeed false when device is not paired, and true if device is paired ! So why can't the API tell me so ?
What should I do ? Thanks for the help !
List of paired devices:
import javax.bluetooth.*
...
RemoteDevice[] rdList = LocalDevice.getLocalDevice().getDiscoveryAgent().retrieveDevices(DiscoveryAgent.PREKNOWN);
Get name & address of paired device:
rdList[0].getBlueToothAddress();
rdList[0].getFriendlyName(true);
Some comments:
list of paired devices can contain multiple devices having the same name
boolean parameter of getFriendlyName() means if agent should query device for its name, but returns cached name if device is not available (at least my tests showed that)
Hi i am little bit confusion about Device Token so can any one guide me. I am using following code for getting DeviceToken.
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)dt
{
}
The above code is working fine and it is showing DeviceToken data ,that is 64 length data.
My doubt is Device Token is different from one device to another device.
If once we got DeviceToken using one device that same DeviceToken can use for another Device.
Of course the device token is different for each device. It identifies a unique device. It's like a phone number (actually it's even more unique than a phone number, since multiple phones can have the same phone number). If it was the same, how would the Apple Push Notifications server know to which device to send your notification?
I am trying to change the name of the Android Device that my program that is currently running on because the name of the device will contain information that is relevant when it communicates with other phones. The name of the phone will be constantly changed as phone scans for other phones and calculates information. Any ideas on how to change the name of the phone within the java code? I can't image it being more than a few lines of code, but I can't find anything.
Thanks in advance.
It's quite easy, get an instance of the bluetooth adaptor (since the only name you can set is the bluetooth name I think) that refers to the local device and call setName("newName"); on it.
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
myDevice.setName("new name");
Quoting the docs:
Valid Bluetooth names are a maximum of 248 bytes using UTF-8 encoding, although many remote devices can only display the first 40 characters, and some may be limited to just 20.
So be careful with what you set as the device name. Oh, on another note, you can't change the name if the device bluetooth is off. So the actual code after checking it would be something on the lines of the following:
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if(myDevice.getState() == BluetoothAdapter.STATE_ON){
myDevice.setName("new name");
}
Important to note:
If you are going to test this on an emulator, beware that there are not bluetooth capabilities on the emulators and therefor the getDefaultAdapter() method returns null, resulting in a NullPointerException :)