In a PhoneGap application, does PhoneGrap translate my code into native code? - javascript

I just starting trying out PhoneGap today. I've heard about it before, and I've always thought it translated HTML and Javascript into native code. After trying it, I think the device is executing HTML/Javascript/CSS directly?
I'm confused as what PhoneGap does. Is my device executing raw HTML/Javascript/CSS or is it executing a translated native code?
By the way, I'm developing on Android.

PhoneGap executes your Javascript in the device's native browser.
It does not compile anything, although the browser's JITter probably will.

Related

How to convert Angular JavaScript code into a native Windows application?

I want to convert an Angular JavaScript app into a native Windows application but I don't know how to do it. I heard that electron could be used for this but I don't know how to use electron.
Despite electron there is another solution called nativefier. It is actually quite simple and you don't have to learn a new framework like electron.
As the comments pointed out already, this is not possible.
Why?
JavaScript can't run directly on the machine, neither do HTML and CSS. You need a browser that can understand those languages and turn them into commands your computer can understand.
So your only way to run an Angular App without using chrome or Firefox or whatever browser, is Electron. It's basically a chrome browser plus your custom Angular app packed into an exe. So under the hood, it really just runs your code in a browser environment, but you have more control over it and no address bar etc.

Interaction between Dart/Objective-C and Dart/Java

I read a really interesting article about how create cross-plateform app : http://www.skyscanner.net/blogs/developing-mobile-cross-platform-library-part-3-javascript
But I would prefer use Dart instead of Javascript, and I was wondering if it's possible to interact between Dart/Objc and Dart/Java (Android), in the exact same way that is showed in the article (run a Javascript VM to execute the javascript code).
Thanks
You can code it in Dart and use dart2js to output JS code then put that JS code in PhoneGap or Cocoonjs to get it on Android/IOS.
The article seems to show how its done with JavaScript. I am sure its possible to code a Dart mobile cross-platform library but it hasnt been done yet.
iOS does not allow 3rd party VMs to be included with your app. The only VM you have access to is the JavaScript VM that is bundled standard with iOS. Even Google Chrome on iOS is crippled in this way (they cannot include v8 on iOS).

Automatic tests for phonegap plugins

I recently wrote a phonegap plugin for Android and iOS (javascript calls native java or objc code and returns results via callback functions in javascript), is there anyway to have automatic testing for it (think ant, maven)? I currently have some asyncTests() using QUnit, but you have to manually see the app running either in the emulator/simulator or on a real device to see if the tests passed.
hej,
im dealing with this problem too. right now I ve found something like this http://wiki.phonegap.com/w/page/36886195/Automated%20TestCases%20for%20PhoneGap and
http://groups.google.com/group/phonegap/browse_thread/thread/723039be2c9df90e
so this may help ;]

Measuring memory usage when developing mobile web applications

I'm writing a mobile web application using JQuery Mobile, JQuery, Javascript. This is my first run at writing a mobile web application so I'm trying things out. I want the program I'm writing to continuously run in the background so I can't rely on a garbage collector and I'm worried about memory usage on a mobile device. I'm being careful to "null" and "delete" vars and functions when I'm done with them but I'd like a tool or system I can use to measure. I'm using CS5 Web Premium as the platform with which I'm writing my code. So...
Question: How do you test memory usage when bulding mobile web applications?
The easiest would be to type about:memory in your GoogleChrome browser and watch the memory usage there.....
You could also use something like DynaTrace to get more details per jscript function (execution times and so on)
The Mobile validator of the W3C http://validator.w3.org/mobile/ Should tell you what size your site is. (How much memory it takes to load) That is if your application is HTML.

Building a Windows app w/ embedded browser & JavaScript 'hooks'

I built a PHP / JavaScript website for a customer. Then they asked me to replicate it except as a standalone Mac application. I did this with an app that combined an embedded web server, PHP, and 'WebView' - a Cocoa-ish version of the WebKit web browser that I can embed in a standard app window. This all worked great - I got to reuse 10,000+ lines of PHP/JS code, which saved months off of re-implementing it all again in 'native' code.
Now they want a Windows equivalent. I'm reasonably confident I can get PHP and the web server to work. And I know embedding basic IE functionality is pretty easy.
However...in my Mac setup, WebView (via the windowScriptObject stuff) gave me the ability to call JavaScript methods from C++. For instance, I might call a JavaScript method from C++ to update the screen. Likewise I could set things up so that a JavaScript call in the browser could trigger a C++ method - I used this, for instance, to let a user click 'BROWSE' and pick a file path using a real, standard file browser.
So my question is, is there a Windows-based embedded browser setup that would let me interact with JavaScript in this same way?
(the JavaScript <--> WebKit interface is described in much better detail here: http://lipidity.com/apple/javascript-cocoa-webkit/)
Maybe try using something like Appcelerator Titanium so you'll be ready when your client says they want it to work on Linux, or iPhone, or Android.
Quoting Wikipedia: "Appcelerator Titanium is a platform
for developing mobile and desktop
applications using web technologies.
[...] Support for standards-based web
technologies: HTML, CSS and Javascript
on all platforms along with PHP,
Python and Ruby for desktop platforms.
Integrated support for popular
JavaScript and AJAX Frameworks
including jQuery, YUI, MooTools,
Scriptaculous and others."
Sounds like a perfect tool for the job.
When you embed the Web Browser Control (IE), your application code can simply call execScript (http://msdn.microsoft.com/en-us/library/ms536420(v=vs.85).aspx) on the window object. You can have your script call out to the application by using the window.external object from the script, and by using the ObjectForScripting (or C++ equivalent) from the application.
maybe Qt will be good for your case, also you have QtScript and can inject javascript with evaluateJavaScript
I found a great example on the web for invoking JS in my embedded browser from C...basically using COM-ish methods that let you get a DISPID from a script object, and then using the Invoke() method with that. This works great.
But it turns out I need to also call C++ funcs from my JS code. It appears this is possible, and after hours of messing around I think I almost had it - it's like the above in reverse - you create a COM object, then hook it to the browser's script object - but in the end I could not close the deal - I kept getting "library not registered" errors. Honestly I don't know COM well enough to do this right.
So then I, for the heck of it, tried building my first C# app. In about 20 minutes I had an app running with a browser where I could both invoke JS inside of it and have the browser invoke C# methods. Geesh. I'm a believer in .NET after this experience, and a confirmed non-believer in 90's Microsoft technology.
In the interest of completeness, I'd like to mention my Windows port of WebKit, which includes the various cross-layer features of WebKit on the Mac.
I posted some example code showing how to embed WebKit in a native WinAPI application, complete with JavaScript->C++ and C++->JavaScript examples.
The example is a tiny test case for a much larger application using embedded WebViews for major UI components. I can confirm that what you are doing is not only possible, but a great way to build an application.

Categories