21.07.2015 Views

Linux Journal | January 2013 | Issue 225 - ACM Digital Library

Linux Journal | January 2013 | Issue 225 - ACM Digital Library

Linux Journal | January 2013 | Issue 225 - ACM Digital Library

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INDEPTHload from one domain, and then loadcontent or code from another domain.However, this program is standaloneand needed to load content froma potentially arbitrary Web site.Cordova handles this problem by“whitelisting” the domains fromwhich an application is allowed tofetch content. By default, all domainsare blacklisted, and, thus, all networkaccess is disabled. A developer canwhitelist a domain by editing/res/xml/cordova.xml and followingthe examples given for the tag. This is a safe but elegant solutionto a potentially nasty problem.Another interesting possibility is tohave your application load all of itsHTML and JavaScript from a remoteWeb server. This easily can be doneby making a simple change to ./src/{projectname}/{projectname}.java. Thisfile has only 20 lines of real code, andthe necessary change is pretty intuitive.Being able to load content froma remote server actually makesdevelopment easier. I found it easierto do my development on a remote,publicly accessible server, than todevelop on my workstation. This way,I could point my Web browser at theapplication and get all my HTML,CSS and JavaScript working the wayI wanted. Then I got the applicationfully functional on my Android. Onceit was fully functional, I copied theproject to my workstation for thefinal build. Doing it this way is theonly way you’ll be able to test anapplication that makes any Ajax callswithout violating your browser’scross-site scripting security policy.As neat as Cordova is, thereare a few things I didn’t like. As Imentioned earlier, there is no wayto detect automatically whether aprogram is running in a browseror on a device. Also, I found thewhitelisting functionality to be abit buggy, but not in any way thatbroke my application. But, the mostdisheartening thing I found waswhen I tried to use the camera API.Instead of simply snapping a pictureand either returning the data orstoring it, the API actually broughtup the device’s native camera deviceas a pop-up. This was extremelyintrusive and actually broke my firstdemonstration app.I’ve had a lot of fun playing withCordova, and I’ve barely scratchedthe surface of what it can do or beextended to do. This has to be theeasiest way to get into smartphoneapplication development.■Mike Diehl operates Diehlnet Communications, LLC, a small IPphone company. Mike lives in Blythewood, South Carolina, with hiswife and four sons. He can be reached at mdiehl@diehlnet.com.WWW.LINUXJOURNAL.COM / JANUARY <strong>2013</strong> / 109

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!