09.05.09
QuickConnectAndroid 1.5 RC_1 Available
QuickConnectAndroid 1.5 RC_1 is now available for download from sourceForge. It includes SQLite access with transactions, recording and playing recorded audio, playing system sounds, vibrating the device, and getting device information such as OS version, time zone, country, etc.
There are examples and source code for each of these capabilities. QCAndroid is now updated to use the same version of the JavaScript QuickConnect framework that QCiPhone 1.5.0 and QCMac 1.5.0 uses. Now all JavaScript should be portable between these platforms. The next upgrade will be QCLinux.
03.19.09
Development Roadmap
I have updated the development roadmap based on Apple’s 3.0 release. The roadmap can be found on the wiki. Let me know what order in which you would like the features implemented.
02.27.09
Android, WebView and AJAX
There has been some buzz about how to do AJAX from within the WebView component of the Android platform. Unfortunately Google has not included the XMLHttpRequest object in the implementation for reasons they only know. As I have scoured the web on this topic I have found many statements about how a work around ’should’ be able to be done, some statements that simply state that it can not be done, and others saying that Google gears solves the whole problem.
Here is the reality.
Can it be done? Yes. Is Google gears the answer? No. It uses the XMLHttpRequest object.
I have spent a significant amount of time exploring possibilities. The solution requires a call from JavaScript down to the Java layer of the application. Simply stated, the Java code uses the HTTP classes, Connection , Client, etc. to make the request and the result is then passed back up to JavaScript.
The ‘gotchas’ are as follows.
- The return value of a call from JavaScript to Java can only return primitives and strings, not objects. Therefore no type of complex dom-like object can be retrieved directly.
- The Android API requires that all communication from Java to JavaScript be done in the form of a URL change for the WebView. This means that data must be URL encoded on the Java side and decoded on the JavaScript side.
- The URL encoder on the Java side doesn’t match the decoder on the JavaScript side. The spaces in the data are converted to ‘+’ characters which remain ‘+’ characters in the JavaScript decoder. This requires that the implementer of a library replace all instances of the space character with some other sequence on the Java side, I used ‘_SpA_, and then replace all of the placeholder sequences with spaces on the JavaScript side.
- The javaScript dom parsing object doesn’t handle XML well. The parsed result of an RSS feed isn’t even close to the XML it is sent.
After spending over a week exploring the possibilities I have come to the following conclusion.
The best way to get AJAX access within Android’s WebView objects is as follows.
- Make a call from JavaScript to Java including the URL.
- Using the Java-side HTTP objects make the request including any cookies stored on the Java side that may be needed.
- After receiving the completed response from the server determine the data type.
- If the data is JSON or HTML URL encode it.
- If the data is XML send it to Android’s SAX parser.
- Send the data to the JavaScript side of the application
- If the data is JSON or HTML do this directly
- If the data is XML use the SAX events to produce a JSON string that represent the XML node in question and pass the JSON for this node back up to JavaScript
- URL decode the data when it gets to the JavaScript side and put any spaces back in the data
- Handle the data in JavaScript
- If the data is JSON or HTML take any steps appropriate for you application.
- If the data is XML assemble a dom-like node structure as each individual JSON string representing a node is received. Once the entire ‘dom’ document is built use it as if it had been obtained using the XMLHttpRequest object.
This approach will work. My tests indicate that this type implementation could mimic the XMLHttpRequest’s functionallity but not necessarily its’ method structure. They also indicate that implementations that use the Java side to make AJAX requests will be too slow. Data sets of any significant size require to much encoding and decoding to be efficient.
I would hate to go through the very large development cycle required to do the implementation described above only to have Google wise up and include the XMLHttpRequest object. At this point in time there are QuickConnectFamily roadmap items that seem much more feasible and demand my time. If AJAX support becomes critical to QCAndroid developers I am willing to do an implementation with the understanding that it may not be usable for significantly sized data sets.
At this point QuickConnectAndroid will not have AJAX support because of the WebView object’s limitations. The hope is that Google will realize it’s mistake and put the XMLHttpRequest object back in the WebKit engine implementation for the WebView Java object. Pressure from the development community on Google may be of help here.
01.18.09
Palm Pre and Mojo
Well, it looks like Palm has adopted the QuickConnectiPhone approach for their new phone’s SDK. In fact it is strikingly similar. Even down to using JSON as the data transfer type between application code and the device.
Hmm…. I wonder where they may have gotten an idea like that? More power to them.
It sounds like a port Palm’s new phones will be only a couple of days.
Developers —- Want to get an idea of how to develop for this new system type? Start working with QuickConnectiPhone or even the recently released QuickConnectAndroid.
In fact, write off of QuickConnect now and you will get an easy move over of your application to yet another device.
Just a reminder, QC is currently available for iPhone, Android and Mac and coming really soon for Linux, Symbian, and Nokia.
I can hardly wait to get my hands on this new Palm SDK.
01.16.09
QuickConnect Porting and Development schedule
I recently got a request for information regarding the planned development and porting of QuickConnect and thought it should be shared here as well.
I am particularly excited about the ad hoc networking. It will be great when an iPhone, an Android phone, a Linux based phone, macs, linux machines and even PC’s can discover each other and not need to care what the other device/machine is. Then an application can be anywhere and interoperate with versions of itself or other services on any of the platforms. And the applications can be written in JavaScript on all of the platforms. Wow.
The current porting situation is as follows:
- iPhone: release 1.1.1 available 1.1.2 next few days 1.5 beta in next few days as well
- Android: beta 1.0 available today if all goes well
- Mac: 1.0 beta 1 is currently shipping
- LinuxQT: beta 1.0 in a week or so
- MobileQT: about two weeks after LinuxQT beta
- Microsoft porting will happen after the MobileQT port is nearing completion.
The iPhone 1.1.2 release will include access from JavaScript to:
- device information – OS, device type, UID
- The iPhone 1.5 beta 1 release will include access from JavaScript to:
- ad hoc networking and service discovery (Bonjour Networking)
The iPhone 1.5 beta 2 release will include access from JavaScript to:
- Raw socket networking (access via the synch cable)
The Android 1.0 beta 1 will include access from JavaScript to:
- Browser and Native SQLite databases via the wrapper
- AJAX wrapper
- Vibrate
- Play Sounds
- Record and Play Audio
- GPS data
- accelerometer data
Android 1.0 beta 2 release will include access from JavaScript to:
- Embedded Google Maps
Android 1.5 beta 1 will include access from JavaScript to:
- ad hoc networking and service discovery
The LinuxQT 1.0 beta 1 will include access from JavaScript to:
- Browser and Native SQLite databases via the wrapper
- AJAX wrapper
- Drag and Drop utility if web view supports CSS transitions(experimenting with this now)
The LinuxQT 1.0 beta 2 will include access from JavaScript to:
- Embedded Google Maps
The LinuxQT 1.5 beta 1 will include access from JavaScript to:
- ad hoc networking
The MobileQT 1.0 beta 1 will include access from JavaScript to(when the device supports it):
- Vibration
- accelerometerdata
- GPS data
- Browser and Native SQLite databases via the wrapper
- AJAX
- Play sounds
- Play/record audio
The MobileQT 1.0 beta 2 will include access from JavaScript to:
- Embedded Google Maps
The MobileQT 1.5 beta 1 will include access from JavaScript to:
- ad hoc networking
01.15.09
Reflections on doing Android development
Some time ago after playing with the Android development API and environment I posted that Android looked good from a developers point of view. After completing the first beta port of QuickConnect to Android I would like to revise that opinion.
The development environment, an eclipse plugin and the emulator, is very unstable. Not only does it cause my machine to freeze up regularly but sometimes it doesn’t even work correctly. For example, when i start eclipse and run my application for the first time in the emulator it fails, every time, to actually install and run the application. So I then I run the application again and instead of using the existing, running emulator it starts another. I then have to quit both emulators and run again. Now the application runs.
If this were all I could easily overlook the environment problems but I now have a much bigger issue. I used the function keys to rotate the emulator to a horizontal position. Now every time I run my application it crashes before it even gets to my code. I have rotated it back, quit both the emulator and eclipse, and even rebooted 3 times. It still crashes. This is with ZERO code changes from when it was working. This seems to be, in general, how the development environment has been to work with. When it does work it is fine but eclipse crashes, freezes my machine, somehow gets in infinite loops, based on listening to my CPU fan, and the emulator is very buggy.
Now to the API and google’s Java Virtual Machine.
Exceptions are not handled well at all. The VM will crash the application instead of throwing Exceptions sometimes. When the events are thrown they sometimes have messages associated with them that are retrievable via the getMessage method and sometimes they don’t. Pattern? I’ve seen none with either of these behaviors. If you are going to roll your own VM it had better be rock solid. Obviously this one is not.
When I first started trying to write code to record audio I didn’t realize that you had to store all files such as these on an sdcard. When you try to write to the native memory using the MediaRecorder it allows you to make the call and then goes into an infinite loop of reads. The log file shows this clearly since read errors are reported infinitely. Hmm….. Maybe this should not be the behavior. By the way, I got the same behavior if I tried to store the audio in a directory on the sdcard. Additional by the way. You have to programatically create a fake sdcard on your machine and then tell the simulator to use it. The creation is uses tools outside of the eclipse plugin.
All in all I have to say that the experience has been quite painful. This becomes especially true when I compare it to my experience in using Apple’s tools to develop iPhone apps. Even taking into consideration the difficult app signing apple developers have to go through.
Google, if you want to maintain your good buzz with developers maybe you should stop hitting them in the head with bad tools like the ones you have produced here. Could it be that you just released it to try and maintain some sort of market share even though it was very far from ready? It seems likely.