Hardware Reference
In-Depth Information
computer or phone. For example, there are methods now
that let you determine the device's orientation by reading
an accelerometer, if you have one built in (and most
smartphones do); reading the compass and GPS receiver,
if they're available; and more.
iOS). You don't need to do anything to that codeā€”it's
just there to act as a shell for your app. You write your
own HTML5 and JavaScript documents, which form the
core of your app. Then you compile it all and upload it to
your phone. PhoneGap also offers an online compilation
service: upload your HTML files and it compiles an appli-
cation for you to download to your phone.
The bad news is that not all of these new methods are
universally agreed upon among the companies who make
browsers. Not every browser gives you access to all of
these features, and not every browser implements them
the same way. For example, the Safari browser on Apple's
iPhone and iPad gives you access to the accelerometer as
of this writing, but the standard browser on Android does
not. So, while it's easy to access devices external to your
phone through the browser, getting access to the ones on
your phone may take a bit more work.
There are things you don't get with PhoneGap. For
example, you can't open a connection to your phone's
Bluetooth serial port, if it has one, nor can you access the
phone's USB connection. Despite that, it's a promising
start.
PhoneGap is not the only platform for developing mobile
phone apps for multiple operating systems. MoSync
( www.mosync.com ) also offers application frameworks
for multiple platforms, but you develop your own appli-
cation in C++, not in HTML. You get access to more of
the hardware with MoSync, but it definitely requires
a greater familiarity with programming than anything
you've seen in this topic so far. Several other companies
are offering cross-platform tools like this now, and more
will certainly come along. If you're interested in develop-
ing applications for the phone that use built-in sensors,
and you don't want to write an application native to each
different phone operating system, PhoneGap is your best
option until the browsers catch up.
X
PhoneGap
If you're interested in getting access to the sensors on
your phone, and you're comfortable working in JavaScript,
PhoneGap ( www.phonegap.com ) is a very promising
option. PhoneGap is a platform that gives you access to all
the phone's hardware sensors through HTML5 and JavaS-
cript. Basically, PhoneGap embedded the phone's built-in
browser engine (which implements all of HTML5's new
standards), added a bunch of hooks into useful function-
ality (such as built-in sensors) and released it as a basic
frame for you to develop in. You download the application
framework, which is written in your phone's preferred
programming language (Java on Android, Objective-C on
 
Search WWH ::




Custom Search