I've been using and coding with bluetooth for quite some time using Java, C++, and J2ME. Java's support for bluetooth is fairly decent although for the JDK you need to use an SDK from a 3rd party – I've used bluecove.org for this. In the past I've used bluetooth for connecting serial devices to exchange data payloads in an XML or ASCII text bump. Today I'm going to see if I can get my droid tablet to pair with my laptop and send something – maybe a picture.
The next step is to make sure that you have the latest and greatest installed. Using the ADK Manager from either inside Eclipse or from the start menu I've added all the latest updates to my current SDKs and also added the new 4.0.3 SDK for tablets. You should be able to right-click the project and click Run As and pick off Android Application.
If that choice is missing then you need to add a run configuration from the same menu – I described this in my earlier post so I won't again here….onto the code! You should run your program just to make sure that all the stuff is working properly – it does take quite some time to startup the tablet OS emulator. It could be that this program just takes a while to load.I found that I had to change my run configuration launch to "manual" in order to select between launching the app as a tablet vs. a phone.
This project is one class file that loads up related sets of widgets. If you look at the code there are a couple of click handlers that pass variables to control what sets of widgets are on screen. The widgets don't really do anything, but you get to see the basic set for your apps. Moving on the Contact Manager example is a good example to look at because it interacts with the base OS data structures for accounts and contacts. The contact manager's main class extends Activity, implements the OnAccountsUpdateListener interface., and initializes the app and gui in the onCreate function. The program contains several utility classes for data handling and synch with the base OS contact/account management machinery. To see the GUI layout look in the reslayout folder and double-click one of the xml files. The Pixel Perfect interface should open up automatically. If it does not switch manually to the perspective – or right click the XML file and use open with to open the editor you want. Pixel Perfect is the GUI layout tool for the ADK. Compared to other GUI layout tools it is a bit odd to work with. Why? There is no visible set of "properties" to manipulate.
Pixel Perfect combines with a few other tools later in the development cycle to help optimize your GUI. These are available through the HierarchyViewer tool – a pretty cool tool that helps you inspect and tune all your screens during run time testing.
This was about Bluetooth right?
Ah yeah – that's right – well let's take a peek at some bluetooth and compare it a bit to J2ME and J2SE in my next post. I want to spend a bit more time messing with the Perfect Pixel stuff.