I am working on an application that connects to a blkuetooth SPP device to recieve some input data. I have made an small android app that can do the job, but I am not sure how to do the same trick from within unity.
Is it possible to write a java plugin or something that can get the job done?
I have now succeded in making a JAR plugin for Unity. It took a while, as the Java ANT setup had to be setup properly and hooked into the Android SDK.
Within this plugin I have implemented an init function that creates a thread connecting to a bluetooth device reading streaming data into a buffer. I also implemented another function that reads data out of the buffer, so now I can get bluetooth data inside Unity.
My problem is now that when the Unity app stops, the thread keeps running and I hae to boot the phone to connect again.
Is there a way to hook into the events of the Activity, so my thread can be stopped when the application is stopped.
Hey Tax, I’m new to programming with unity and android and could use the functionality you made. Can you post your plugin and/or a how to? Maybe this is basic for everyone else, but it could be also be really helpful.
Uuh, it was a long time ago… I just succeeded in writing a plugin that could connect to the Android bluetooth stack. It was not pretty and the code has been taken over by the client I was working for at the time.
I would recommend studying the android BT stack and make it work with you device on android first.
When that is working you would know what functions are needed to be implemented in a plugin for it to work with Unity.