I've found a problem during the integration between IBM MobileFirst 7.1 Apps and wearable devices (Android Wear / Samsung Gear) like companion apps.
We are working on IBM MobileFirst 7.1 Hybrid Application that work with wearable watch devices as an Host for Web services integration via adapters invocation.
We implemented an Android Service in Java using native MobileFirst SDK for Android using these class: WL.Connect, WL.Client and WL.invokeProcedure to call Mobile First Adapters.
Below the code used into Android Service used for initializing the client (smartphone host):
final WLClient clientC = WLClient.createInstance(this.getApplicationContext());
clientC.connect(new WatchConnectListener(adapterName, procedureName,parameters))
The connection was done successfull but the WL.InvokeProcedure raise an error.
Below the error received during the execution:
Calling startActivity() from outside of an Activity
After an investigation we realized that this error is related to the Context passed to the create WLClient.createInstance, the context passed need to be an Activity but in this case the context is an Android Service.
Could somebody suggest how to use WL.Client() into an Android Service for wearable communication ?
I suggest that you will make a feature request (RFE) for enhancing the Android SDK with support for running on watches so you could implement such scenarios. Right now this is not supported.
Make the request, here: https://www.ibm.com/developerworks/rfe/ and let your IBM representative know.
Related
Is there a way to check the connect ability of a BLE device in Xamarin.Forms (I'm using Plugin.BLE)? I need a method (similar to isConnactable) that will check the connect ability of each element from the ObservableCollection. I'm developing an Android application, so cross-platform is not necessary.
Sample illustration in code:
ObservableCollection<IDevice> DevicesList = new ObservableCollection<IDevice>();
ObservableCollection<IDevice> IsConnactableDevicesList = new ObservableCollection<IDevice>();
DevicesList = new ObservableCollection<IDevice>();
IsConnactableDevicesList = IfDeviceConnactable(DevicesList);
Do you mean the connectable property sent in the advertising packet? (i.e. https://developer.android.com/reference/android/bluetooth/le/ScanResult#isConnectable()). It seems your chosen library does not expose that info. You can skip the plugin and call the native Android framework directly to get this working, since you don't need cross platform compatibility anyway.
You can also modify the plugin to make it expose this info.
So my android app is behaving as a beacon, means, it will be advertising and other BLE devices will be connecting to it. Well, this is how our project is working so please don't raise questions on this as why am i using my app as a beacon and not as a scanner. Anyways, It behaves as a beacon and starts advertising and now I want to know that if a device connected to it. I cant find a way how to do this.
Of course, I am using this flutter package. beacon_broadcast 0.3.0
This is my code.
void startAdvertising() {
BeaconBroadcast beaconBroadcast = BeaconBroadcast();
beaconBroadcast
.setUUID(advertisingUUID)
.setMajorId(1)
.setMinorId(100)
.start();
}
First, Flutter is just a UI toolkit and has no support for other system APIs such as Bluetooth.
You should therefore look what the official Android APIs offer in the first place. Usually when using BluetoothLeAdvertiser for advertising, one often also adds an instance of BluetoothGattServer in order to handle connections. If you have created a BluetoothGattServer using openGattServer, you will get a onConnectionStateChange callback whenever a device connects or disconnects. So that answers your question how an Android app can get notified when a device connects. You probably also want to use the same API to add a GATT service so that the other device can communicate with your app. Other alternatives is to use the GATT client API if it's the other device that has a GATT server, or you might want to use the L2CAP CoC API.
Note that if Bluetooth is turned off/disabled/restarted, your BluetoothGattServer object will automatically die and you need to recreate it. To get notified when this happens, use a state change intent receiver for BluetoothAdapter.ACTION_STATE_CHANGED as explained in this example https://stackoverflow.com/a/9694138/556495 to recreate your BluetoothGattServer (and advertiser) when state is changed to STATE_ON.
Now, since you want to use Flutter but Flutter uses Dart, you cannot directly consume the Android APIs. Instead you need to write a bridge/plugin, to bridge your Dart code and Java code. See https://docs.flutter.dev/development/platform-integration/platform-channels for a tutorial how to do this. If you're lucky, someone else might have already created such a package that does exactly what you want. Unfortunately, the beacon_broadcast package you found, only implements BluetoothLeAdvertiser and not BluetoothGattServer, as can be seen by the source code here: https://github.com/pszklarska/beacon_broadcast/tree/master/android/src/main/kotlin/pl/pszklarska/beaconbroadcast.
I've implemented SIP feature in my app. I am currently working on Galaxy Tab SM-T580 with Nougat. Problem started at the moment when I've decided to upgrade Android (from 6.0 to mentioned 7.0) - then my SIP client stopped working.
When I try to open my sipManager implementation with open(sipProfile, pi, null) method
android.net.sip.SipException: SipService is dead and is restarting...
at android.net.sip.SipManager.checkSipServiceConnection(SipManager.java:183)
is thrown.
Debugging code I can see that SipManager from android.net.sip doesn't bind Context.SIP_SERVICE service (SipManager:175). Code and configs I am using are copy paste from Android Docs - Android Sip Guide
I'm trying to build a simple Qt based Bluetooth Server (rfcomm) that just prints in the console the text that is sent by the client. I've noticed that when I'm using QCoreApplication(this is what I need) instead of QGuiApplication or QApplication, I'm not able to receive any message and I'm not notified when a client is connected (SLOTS are not called).
The entire code can be found here. The server can be tested with Qt Bluetooth Chat example and the entire code of my server is extracted from the example. It could be something related to the event loop but I don't know what. I'm running the server on OS X El Capitan with Qt 5.6.1.
According to the Qt team response on this reported bug Bluetooth I/O related functionality needs a running loop which is not available through QCoreApplication.
Qt 5.7 has a workaround for this - using Core Foundation event dispatcher.
To activate this event dispatcher you'll need to set the 'QT_EVENT_DISPATCHER_CORE_FOUNDATION=1' environment variable.
I am into a new project which requires me to use a USBconnected "Webcam".
The whole fun should run on Android 4.4.
my little story was:
I try multiple apps which do this - all work on both my testing devices
adapting some NDK lib that directly uses /dev/video0. This didnt work due to read-permission that was not granted in a new File("dev/video0").canRead() check. Although my unix permissions are correct, this seems to not work due to some new check on Android 4.4. (the whole thing was suggested here: Connect Android phone to a USB Web camera )
next: discover the UsbAccessory API that supposedly easens a lot of the above.
´find no documentation or anything about how to correctly handle a webcam
I still try, but don't come further than finding no device via
usbManager.getAccessory();
I've also tried to discover devices by filtering for a USB_ATTACHED broadcast but nothing triggers.
So I am starting to ask myself how the hell do others find the devices & communicate with them to get the pictures?
Anyone has sources from which i could learn, or a tutorial or something?
Little update from my side:
- I've gotten access by using the Android USB Host API e.g. UsbDevice instead of UsbAccessory.
- I have the connection and everything setup fine, and can now send binary data to my webcam and supposedly receive.
I can now send controlCommands via connection.controlTransfer(...) or use a "UsbRequest" in order to receive data.
However, I couldn't find any documentation to "make the camera submit pictures" to me. My Endpoint is of type XFER_INT (=interrupts).
I am continuing to try sending out various commands (e.g. binary values) but haven't had any success so far.