When to use HTML5 in android? when don't use? - android

What are the situations a developer need to use HTML5 in android.
I am bit confused about when to use HTML5 in android.
I need to develop an application like a report viewer from web server.
In this case i also need to use some Android specific features like service, preferences, receivers, charts (with the help of third party library).
So i am little confused about what are the good situations to HTML in android apps...
Please help me by your suggestions or direct me a better article about this...

Please read this pdf . You can get better idea where to use html or where to use native android apps.

Android is to date the platform with many variants of using different browsers: WebKit-based Android browser, Opera Mini, Opera Mobile, Firefox, UCWeb, Google Chrome Android browser.
The default Android browser has some problems with HTML5. And the Chrome for Android is designed to solve it. It has almost perfectly latest HTML5 support: such as new elements, video –H.264 and WebM support- and audio tags, geolocation, hardware accelerated canvas (2D drawing), and all the CSS3 stuff, such as selectors, effects, media queries, transforms, transitions and animations, ect.
But while it's still not very popular because this new browser isn't available yet for Android 2.x and 3.x version, just for 4.x.

Related

Is there any way to use Flash in an HTML-based mobile app?

We're trying to combine HTML and Flash in a packaged mobile app. It needs to work on Android and it would be nice if it worked on iOS as well. One option is to use AIR with an SWF root containing a StageWebView, which should work, but we'd prefer to have the root of the app be in HTML and loading the SWF content as needed. Is there a way to do this by, for example, using Phonegap/Cordova or similar, perhaps with a plugin?
That's not possible. There's no plugin support for IOS.
The android situation only is slightly better since Adobe stopped publishing the plugin after/with Android 4.2. Older devices that have the plugin installed would work, the rest wouldn't. Also Adobes usage terms for the plugin wouldn't allow you to bundle it with your application if they didn't completely changed it since I checked it some years ago.
There are some solutions that might be providing you with what you look for some day, but they are not ready yet IMHO. Still, here some links:
https://github.com/mozilla/shumway SWF-Player implemented in Javascript
https://www.google.com/doubleclick/studio/swiffy/ Flash content to HTML5 converter
That means right now Air is your only serious option if you want to combine Flash and HTML on the same mobile device.
If you are still in the planning phase of your project or willing to rework the code you could also evaluate Haxe/OpenFL which is NOT FLASH but would allows you to develope your application with the Haxe language (similar to AS3), work with a Flash like display model - and then export the project as HTML5, SWF (also Air) or native Mobile applications for IOS/Android:
http://www.openfl.org/
http://haxe.org/
If you want to have HTML as a root, it means that you will run Flash Player as a plugin. Since 2012, Adobe stopped supporting Flash Player for mobile. Which means that it can be done easily - as just embedding your swf into HTML page, BUT it won't run on almost any device. That's because the player must be installed as a plugin for the browser. What you want is to embed the swf just like you're doing it on your desktop, and pray that the browser has it installed and run it. Nowadays most of the devices do not support it.
There isn't any easy workaround, because of the fact that Adobe cut the rope. And it's the proper way that should be done, as that Flash would be a part of an HTML. It won't have access to any hardware nor it would have permissions for writing and things like that.
So if you want Flash inside mobile, it's almost certain that it must be within AIR - it's native wrapper.
And the short answer basically is - yes, just embed it as swf inside HTML, but it won't work on much devices :)
I want to warn you that mobile webView has a lot of issues and limitations. As for me it is extremely bad idea to put flash player inside mobile webView (it looks like the castle in the swamp).
AIR as root application is definitely better solution (but anyway StageWebView brings a lot of pain too, it is just wrapper around native webView afaik).
Well, but if your choise is HTML, try to patch cordova\phonegap template (find there CordovaActivity class) to enable flash content as following:
WebSettings settings = appView.getSettings();
settings.setPluginState(PluginState.ON);

Is it possible to develop pure HTML5 applications with PhoneGap?

Even after searching PhoneGap's website and their support group, I still cannot find an answer to my question:
Currently, I'm planning on developing an application that should exists as a pure HTML5 application, being able to run in any modern browser (Google Chrome, Safari, etc.) as well as on Android/iPad as native mobile applications.
So my question is:
Is it possible to use the same code base to develop both pure HTML5 applications as well as native mobile applications with PhoneGap?
PhoneGap is in effect a runtime environment for HTML, javascript, and any CSS that may accompany your code. So in short:
Yes, but it is recommended that you have some knowledge of Objective-C if you want to develop any iPhone app with extended functionality. If you have the right dimensions/proportions for the code there is no reason why you cannot simply copy that code into PhoneGap and compile it.
See, the support for #HTML5 varies from browser to browser, and varies a lot from a desktop browser to mobile browser. If one has to convert web-portal to a mobile application that can easily be done through Phonegap, you can refer to this link also. https://build.phonegap.com/ It worked fine for me.
Now lets come to Phonegap, what phonegap does is it has created wrapper through javascript that calls the native apis. Now to show content they use WebView object which renders your html5 page in your app. And you can create your own wrappers too. Not that much difficult.
So if your app is only a web based portal, that does not need much native access, you can easily reuse one codebase make #cross-platform apps using Phonegap. Else you need to go for hybrid apps.

Offline Web Application HTML5 on Android

I want to develop a HTML5 Web App.
I read that in HTML5, you can use the new feature "Offline Web Applications"
With the *.manifest file
I read an article from november 2010, that this feature only works on the iOS platform.
Does it work on Android now?
Yes. It works on Android as well as iOS and most desktop browsers. You don't need PhoneGap unless you want to access native features or deploy to the App store.
UPDATE:
Check out this chapter from Jonathan Stark's book: Building Android Apps with HTML, CSS, and JavaScript.
In general, http://mobilehtml5.org/ provides nice mobile compatibility tables to answer this and other similar questions.
Yes it can. Here's an example for an offline game:
http://www.davidgranado.com/2010/11/make-a-set-mobile/
The one thing that sucks is that iOS generates a nice icon automatically. However, android doesn't. Also, I noticed that on random versions of android, it will display an error popup about the fact that it can't connect to the internet, but still runs fine after that.

Deploy WebGL applications as native iOS or Android applications?

Does anyone know of a way in which you can deploy a WebGL app as a native iOS or Android app? Commercial middleware is acceptable, although an open project would be preferable. Thanks.
As an extension to Joris' answer (which appears to be based on the work of Nathan de Vries), the following is the code I needed to enable WebGL within the iOS 5.0 SDK:
Somewhere near the top of your view controller implementation:
#interface UIWebView()
- (void)_setWebGLEnabled:(BOOL)newValue;
#end
Programmatically creating a UIWebView and enabling WebGL:
UIWebView *webDetailView = [[UIWebView alloc] initWithFrame:mainScreenFrame];
id webDocumentView = [webDetailView performSelector:#selector(_browserView)];
id backingWebView = [webDocumentView performSelector:#selector(webView)];
[backingWebView _setWebGLEnabled:YES];
I created a sample application that demonstrates WebGL running in a iPhone / iPad fullscreen UIWebView, using the WebGL scratchpad site http://glsl.heroku.com as a destination. Be wary that some of those examples there will grind even an iPad 2 to a halt, potentially leading to a hard reboot. The performance there seems to indicate why WebGL is still in an officially unsupported state in mobile WebKit.
Of course, as has been stated, this is not guaranteed to work on future iOS versions and will get your application rejected from the App Store. This is only really useful for hobby work and internal testing.
An example of WebGL running on my iPad 2:
WebKit on iOS actually supports WebGL, as of 4.x (not sure which .x version). It is enabled in the webview used by the iAd framework, all other uses of WebKit (Safari and UIWebView) have WebGL disabled.
It is possible to enable WebGL using private API's (this will not pass the submission process). In your webview subclass:
- (void)setWebGLEnabled:(BOOL)enableWebGL {
UIWebDocumentView* webDocumentView = [self _browserView];
WebView* backingWebView = [webDocumentView webView];
[backingWebView _setWebGLEnabled:enableWebGL];
}
(via)
This will at least allow you to start experimenting with WebGL on iOS.
Not sure about WebGL support on Android. Fairly recent comments on the issue in the Android tracker suggest it is not available yet.
A nice support table for WebGL in (mobile) browsers: When can I use WebGL
Best way to go for now seems to be to include your own WebGL enabled version of WebKit in your application wrapper for both iOS and Android.
As the iOS version of WebKit doesn't support WebGL natively, I think you have two options:
Implement the WebGL API in the JavaScript context of a WebView yourself by forwarding calls to the native OpenGL via iframe RPC or so. There isn't a clean way of calling (Objective-)C functions from JavaScript on iOS, unfortunately. Performance could be a problem.
AOT-Compile or interpret the JavaScript in a third-party runtime, then implement WebGL from there. JIT compilers are disallowed on iOS, so something like V8 won't work. Appcelerator Titanium statically compiles JavaScript as far as I know, and also has an interpreter. You could use that, but you'd still need to implement the WebGL glue yourself.
I'm not aware of any existing WebGL bridges for iOS, so I think you will need to either write it yourself or get someone to do it for you. One problem that might not be possible to overcome is if you use anything other than WebGL to display stuff - e.g. HTML, 2D <canvas>, etc. Combining WebView display with an OpenGL framebuffer is going to be rather tricky.
I don't know much about Android, but considering the rules are more relaxed there, it might be possible to embed a WebGL-compatible browser there.
I don't think there are any easy converter tools. You'll probably have to take your WebGL codebase and rewrite in OpenGL for both platforms, to create native apps.
It's not ready yet, but ForPlay may be able to act as a common development platform for Android and WebGL via GWT.
Bundling WebKit and your app's resources (.js, textures, etc) into an iOS or Android application doesn't sounds too much difficult. I'm assuming that since Google and Apple are major contributors to the WebKit project, all the required support (for multitouch and other stuff) is already there.
PS: many iOS apps use interpreted Javascript or Lua. The rules are there to prevent your app to execute 3rd party code (esp from the internet), not the code you'd bundle in your own app.
EDIT: To clarify, I think you'd need to implement your own web view using webkit (built from source) in order to use WebGL and pass Apple's screening process, as activating WebGL in the Apple-provided web view will get your app rejected.
There are a couple of options to be able to deploy a native WebGL app. EjectaGL is a great WebGL implementation but a little bit harder to master (http://codehum.com/stuff/ejectagl/).
Another option is Ludei that recently announced their support for WebGL on both iOS and Android. It is easier to use and supports acceleration for HTML5 canvas in both 2D and 3D through WebGL. It also provides a way to monetize your app using IAPs, ads and plenty of extensions. It is much easier to test using the CocoonJS Launcher App and their cloud compiler.
www.ludei.com
http://blog.ludei.com/webgl-demos-arrive-to-google-play-store/
Try Phonegap. It allows you to build "native" HTML+CSS+JS apps using the standard Webkit installation on your OS. And it provides a javascript-to-native bridge to allow you to do things not possible in pure webapps.

Roadmap for HTML5 features in WebKit for Android

I recently tried out the applicationCache / offline web apps on Android 2.1's WebKit and unfortunately it does not work exactly like on a webkit on the iPhone. I was wondering how I can easily see what features should be implemented and if there is something like a roadmap?
Does that information somewhere exist?

Categories

Resources