How phonegap really works? - android

It is just a webview that have many api to native functions?
Can I have a phonegap activity and a native activity in an app?

(1) Yes...PhoneGap provides a setup for every major mobile operating system that will create the same environment everywhere. This consists of a webview and a set of javascript functions that are mapped to native functions. This way you only need to develop one applications (based on HTML, CSS and JavaScript) and it can be run on any OS PhoneGap can provide its framework for.
Your application <--> Phonegap <--> Android
Your application <--> Phonegap <--> Windows Phone
Your application <--> Phonegap <--> iOS
Your application <--> Phonegap <--> ...
It takes having to deal with different operating systems away from you and instead you can focus on building your application, because you only "talk" to Phonegap and it will talk to the OS for you.
(2) Mixing the Phonegap webview application that is actually run by the phone with native stuff specifically created for one operating system will most likely end in disaster. That's not how Phonegap is supposed to work. And breaking out of PhoneGap's "jail", meaning it's JavaScript framework and the webview, will probably not work anyway. You can, however, open other applications on the phone and receive values from them. The question always is: On how many operating systems is this functionality available?
If you start asking questions like the one you just posted here... maybe you should first check that PhoneGap really is the right tool for what you want to do.

It is not a phonegap activity. It is just a web view that uses phone gap javascript functions. Thus you will not have such problems. You can easily implement most of your UI using HTML, still using some native controls for menus, animations etc.
Phonegap actually is a library that translates your javascript calls to instructions for the different OS like Android/iOS/Windows phone.

Phone gap is a intermediary layer that talk with your phone & between your application. Your application resides inside a chrome less browser & using phone gap api you connect to phone features like contact, camera, io etc...

Thus actually phonegap works.
Phonegap really works in 3 steps:-
1- Build App with Web standards: Developers already know how to make a web technologies using html5,css & javascript.
2- Wrap that with Phonegap: Using this phonegap build,one can get access to native API’s
3- Deploy to Multiple platforms: Phonegap actually uses standard based web technologies to bridges web application & mobile devices.

Related

Is it possible to make an app for android + iOS that is actually just a web app?

I'm enjoying web development and I want to make an "app" to try my hand at mobile phone dev. Learning Java/AppleCode isn't feasible right now, so would it be possible to make a website that runs as an app on a phone? And have that app do the things people want apps to do, like integrate with your phone's calendar, receive notifications in the notification bar at the top (Android), etc...??
Yes.
Apache cordova will do the trick but you (of course) can't have php running, only html and javascript are supported (and the code in which the app is built).
Featueres :
Free :)
Code for multiple platforms in html and js.
Tons of plugins to do all kind of stuff for you.
Can (with a little modification of content security policy) load pages from a remote server.
Downsides :
Not the performance of normal code.
Only communication between app code and js is using callbacks, this results in true Callback Hell.
All app code runs asynchronously while js code doesn't.
Installation is not a simple .exe but an actual guide (i managed to screw it up, had to system restore to easily remove created files. But it should be rather simple).
Supported Platforms :
android
ios, can't compile for ios on non-apple though (thanks apple!)
browser (basically webserver)
windows
windows 8 app
windows phone 8
blackberry 10
and more...

Building the app for Web also

Can Nativescript build apps for web as well?
As Ionicframework and similar uses Cordova to build Android and iOS the same code there can be served by an HTTP server to the mobile or desktop browsers.
Will that be possible with the apps built with Nativescript, using same code base for web version of the app?
Nowadays Angular integration is on the way, and using Angular for the mvc kind of things (like data bindings, events etc.) and using Native for the device apis, platform apis and native gui would help in an unequaled way.
Angular parts can be used in the browser as well when built for it. What to do with the xml written for the gui templates in Nativescript, they could be converted to proper html for web built of the app, as Nativescript itself already uses a unified gui api for different platforms, that could be possible. And lastly, native calls made in NativeScript would be ignored in the web build.
It would be great to build for Android, iOS, and Web with the same exact code base.
tl;dr: No
Longer: The big difference between the Cordova/Phonegap based technologies (such as Ionic and Supersonic) and the Dynamic Runtime based technologies (such as NativeScript, React Native and Titanium) is that the first uses a HTML approach where the application is run by WebKit/Blink in a WebView. Looking on the Dynamic Runtime technologies there's no HTML Engine running your app, but rather native views and widgets. The framework (in this case NativeScript) is "just" a bridge between Javascript and the native language of the device.
However, depending of how you architecture your code, you can create Javascript which will be usable in both a NativeScript environment as well as in a browser environment.
Edit: The above means that you could reuse some of your code. There'll still be NativeScript specific code.
Edit2: There's an ongoing project to enable usage of Angular 2 in NativeScript. Please see current status in the issue: https://github.com/NativeScript/NativeScript/issues/103 Also note that the Telerik NativeScript core developer Valentin Stoychev is saying
The idea [is] to enable as much code reuse as possible between your web and mobile apps.
So: Yes on code reuse - no on exact same codebase.
Adding to the (correct) response of Emil - I do not think it is possible to have any significant portion of the app shared (even for the logic part) since {N} apps mostly utilize the Nativscript observable implementation which would probably 'leak' into your models / view models.
Having said that, I suggest you to monitor the work happening on integrating Angular2, which would probably mean a larger code sharing potential (with Angular2 web apps)

webview across the platform. Architect View?

I have a c,linux background with less knowledge about web application. I came across some strange requirement, and finding difficult providing solution.
Requirement in Short:
One Code/multiple platforms[ mobile as well as desktop]
What I know:
1) UI Front.
Webview is provided across all mobile, desktop applications.
[ Atlease I know for: iOS, Mac, in Windows/Linux/Mac from QT ].
Conclusion: I can have html5 code, which can be utilized across desktop/mobile platform.
PROBLEM: How to do the native access from HTML/JavaScript. We could go with the phonegap which
supports Only mobile, but not desktop [ Correct me if I am wrong]. And if we go with QT, then
not much support for android/iOS [ Correct me if I am wrong].
2) Writing Middle layer in c++:
iOS/Windows/Mac/Android supports C++.
Question:
In iOS/Android I know how to bring the webview using Xcode. But how can I get the webview in Windows and Mac.
In Short, do we have any open source framework that supports Mac/Windows/iOS/Android
Is it possible to write our own Native function invoke mechanism from JavaScript to the C++ code,
which is common.
Kindly suggest.
Answer :
You can launch the application by opening the browser or as plugin to browser,other wise for mobile webkit you need to have it ported on the platform u wish to run your app ie Mac,Windows ,etc
U can easily partially port code in multi-platform ,However u can find many opensource SDK like phonegap , snehaTouch ,etc to have application for all smart phone, but not for mobile and desktop/laptop environment, multi-platform destop/laptop you can go with Java application.
Yes you can call native function in respective platform by invoking from webkit using javasript .,
So single code can either work in mobile OS , or counter part writing Java?c++ code will work in all Desktop/laptop OS

Is PhoneGap the right choice for me?

I am new to PhoneGap, and I have several questions:
I need a way to develop an application that will have iOS, Android, and other platform compatibility. In other words, I want to write 1 app and get compatibility versions for different platforms.
By reading the "Get Started" guide linked by the PhoneGap website, I found there are different procedures for different platforms. So to have compatibility versions across platforms, do I have to go one-by-one and change all of them if I make a modification to my app?
Also, what exactly is PhoneGap Build? It seems like I can avoid all that hassle mentioned previously and toss my app into the PhoneGap Build? Do I really not have to do anything besides writing the app? What if I need to make changes?
And finally, I've read that PhoneGap works with HTML, CSS, and Javascript, but not PHP. What if my app needs to contact a server? Can PhoneGap handle that?
Thank you for bearing with all these questions!
PhoneGap achieves platform compatibility by embedding a webview within your application. Therefore you can apply your knowledge in HTML, CSS, JavaScript and it additionally provides ways to interact with native features (e.g. camera, gps, ...).
With PhoneGap you write one general web app, tweak parts for the specific platform (sometimes you do not have to this at all) and build it for that platform. The latter can be handled with PhoneGap Build service: It takes your webapp and bundles it for the mobile operating systems out there (Embeds it within a Java app on Android, an Objective-C app on iOs)
PhoneGap is able to communicate with a server hosting a PHP script just as every other web application. Trying to dynamically load resources from remote sites can be quite a hassle but this is another question.
traumalles is correct. All your HTML/Javascript/CSS is running from within a webview on the device. Your code is, therefore, all "client-side." You can communicate with a server just like with any other page. When they say PhoneGap isn't compatible with PHP, they mean only that PhoneGap can't execute PHP code like it's a server, because it's not. It's just loading your webapp in, basically, a browser.
One other important question is what exactly do you mean with "other platforms" phonegap does provide many functionality for nearly every platform but the different webbrowser of the mobile devices have their problems and limitations.
For example are there many problems if you want to provide your application on a WindowsPhone Device because the Webbrowser has a few limitations which will cause your app to not look and behave like a native app.
Just look a bit through the phonegap API you will see that some functions are just available for IOS or for Android and there are a few only Blackberry methods and so on.
So you really have to be careful when a framework tells you it will work on all devices.
So i really don't have a problem with phonegap i worked with it very great but there will be limitations you have to deal with.
If you primarily want to develop for IOS and Android you can really achieve great native like results !

Which native APIs from Apple and Android devices can Appcelerator access which Phonegap cannot?

I am aware of Appcelerator and Phonegap's differences with regards to their approach in creating cross device/platform applications for Android and iOS. I believe one of Appcelerators advantage is that it has access over the device's API, correct me if I am wrong but isn't Phonegap also capable of accessing the device's API? My question is if both of them has access to the device's API, then what advantage does Appcelerator have over Phonegap in terms of API coverage? Which native APIs from Apple and Android devices can Appcelerator access which Phonegap cannot?
With the typical PhoneGap application, you're trying to mimic the native GUI elements in JavaScript, most likely with something like the Sencha Touch framework. However, with Titanium (Appcelerator is the company, Titanium is the product), you're using Native GUI elements.
To answer your question, when you're developing a simple application in PhoneGap, you're not using the native Table View, Tab View, Image View, etc. Instead, you're using JavaScript that tries to mimic those controls. So, in even the simplest of cases, you're not using native APIs with PhoneGap.
Considering you're able to write your own native code for either Android or iOS using PhoneGap, I don't think there are actual limitations in terms of API coverage beyond what comes with it out of the box. I just finished writing a plugin for PhoneGap that allows me to access the orientation gyros (ie yaw, pitch, roll) on Android because it didn't have one. Since PhoneGap fires up your class on initialization, you're able to inject whatever code you need before/after executing the super.loadUri statement.
PhoneGap is simply a wrapper that makes it easier to separate your presentation layer from the native device code by automatically loading up an html file in a chromeless browser and then listening for specific requests made from the browser back to the native code (ie, the plugins PhoneGap ships with). You're free to add additional native code around the PhoneGap wrapper.

Categories

Resources