Sockets in WebView Android - android

Im having an application written in .NET (i guess) and is quite responsive. The idea is to wrap the app as an android app. The android app is going to have many more functionalities and this webview is just one of them.
My question is the current web app is using some sockets to push data to the page. So the content changes without refreshing the page. Will that functionality be intact in android webview too?
I should have tried this by building the app, but my bad they currently do not have any data and aren't pushing either.

I ran into the same issue. From what I can tell, Android browser (aka WebView) does not support WebSockets : http://mobilehtml5.org/
Although there is a workaround using Socket.IO which you can try out: http://chpeck.tumblr.com/post/37273036645/socket-io-with-android-webview
Gist: https://gist.github.com/secobarbital/4220309
Another easier alternative is to use Pusher on your website, which will automatically fall-back to Flash if it detects a browser that does not support WebSockets.
EDIT
In Android 4.4+ original WebKit-based WebView has been replaced by Chromium which supports WebSockets among other goodies. More info: http://www.mobilexweb.com/blog/android-4-4-kitkat-browser-chrome-webview

Related

Native App only or WebApp with Native App on top?

I want to build some kind of multi-user blog that should mainly be used via smartphone but CAN be used at a pc/mac too. I want it to be stored in the iOS and Android AppStores, so just a webapp with mobile-view option doesn't seem right to me. Now my question. Whats the best option to start with? Create the webapp first to get the backend, databases and stuff and than write the native app that gets access to that databases? Or start with native app first and just build a simple webapp that gets access to the native app backend? Or maybe write the webapp with mobile view option and just write a simple native app that uses the UIWebView to show the mobile version of my webbapp? I hope this question is not too confusing^^
P.S. I decided to go for ruby on rails for the webapp and store that stuff on amazon aws ;)
P.S.2 How much is the UI of a native app customizable e.g. TableViews etc? Because implementing WebApp via UIWebView may be the more stylish option?
greetz
Look, Native UI will have quite good performance event on old Android devices,
but it requires some development effort to work with Android SDK. On another had you can create some hybrid webapp using Phonegap, but you shoud keep keep in mind that you may have some performance problems with slow-slow android's web view.
As for me blog app could be implemented with lightweight JS/HTML5, but in this case please don't use Jquery/ jQuery mobile - they are extremly slow, and I experienced huge performance degradation.

Using Webrtc in Native App

My questions is :
1 -- Is it possible to have a WebView( Provided by Native framework) instance in my Native App , and extend it to support Webrtc,
if 1 is Yes, then probably following would be the action Item
1 -- Have a webrtc build on Android, 2 -- In Android WebView extend Javascript to couple / bind the Webrtc call,
Please confirm..
What i am trying to do is
1 -- We have webrtc based Voice / Video chat application working fine in Chrome & Mozilla desktop Browser, as both comes with webrtc... , i.e. user need to access www.xyz.com and it will start video / voice sessions,
2 -- same thing on mobile, we would like to go as a native app, i.e. we are trying to make an application, which will have native WebView instance, in which we will access www.xyz.com to have voice / video session
3 -- I tried the way i explained in 2 but it seems, in WebView instance provided by Application framework doesn't have webrtc enabled in it, so i am trying to add it and this is what i am thinking,
-- WebView instance has some mechanism to extend the Javascript , that means
http://dev.w3.org/2011/webrtc/editor/webrtc.html
some of these API i need to add into the WebView, and for their implementation will come if i am able to successfully integrate and build Webrtc over android and iOS Platform
Please comment....
If you want to use webRTC in a Native App, i've built a small android app (https://github.com/pchab/AndroidRTC) that share the back camera to a nodeJS server (https://github.com/pchab/ProjectRTC).
I found that the easiest way to use the libjingle library is with IntelliJ IDEA. I've had a lot of problems with Eclipse and Android Studio.
You're going to have a hard time with the WebView, although it's coming on (newer) Android at least. Nothing on the horizon for iOS.
If you want complete native, you can check out what we've done # FM with IceLink, sounds like it might work for you.
Android WebView does not support WebRTC APIs at this point.
Work is underway on Java an Objective-C bindings, though that may not solve your problem.
With Android L release this should be possible by using just the Android WebView, more below :
http://developer.android.com/about/versions/android-5.0.html#WebView
I know this question is kinda old, but I find crosswalk (https://crosswalk-project.org/) to be a pretty good solution for using WebRTC inside of an Android app. What crosswalk do, is compiling a chromium browser into an Android app and hosting your site inside of this chromium, so you will have support for the latest browser features, like WebRTC.
I'm building a native app with a webview and webrtc video inside.
So generally it is possible to build such application and nowadays chromium (webview) have a official support https://developer.chrome.com/multidevice/webview/overview , but I have faced really a lot of problem during writing that application.
Few problems are:
Support for phones and os version - I have android 5.1.1 (xperia m2) and after a lot of problems webrtc is running. On android 6 (xperia z5 compact) is not working.. On other phones is sometimes working sometimes not...
You can not be sure, how webview will work - today webrtc is working, but tommorow Google can add some security rule, and it will not work- it's a little bit unstable, and as I have seen, some things depend on os compilation. WebView can get update from store independently of os.
PERMISSIONS - there are a lot of stupid problems, based on the fact that is it a browser inside native app, like - you can't expect a permission question from webview, you have to implement it in android webview config, and in some android versions it is working- in others not :-)
Still a lot of problems of 'young product' - example is that nowadays webview has some issue with devices info display (like camera is front or back) so you have to find a workaround for such problem
Bad video quality - currently my problem is a quality of video- nice quality of video on phone, below maximum resources consumed (cpu, network, memory) and video on computer is really poor...
...and many more
So the fact is - yes this is possible, but it's still not good enough to use it without facing a lot of problems which are not so easy to solve.
You can actually go native with html5 features. So if you use Crosswalk as someone mentioned before, but if you are really set against using: Crosswalk/Ionic/Angular/Cordova (which is awesome), you can still use Crosswalk in a native environment to replace inconsistent and feature lacking WebViews with 1 single, full WebRTC compatible WebView based on the Blink Engine.
I remember reading a few guides on how to get Crosswalk going in Android Studio, here's one I quickly searched, but just Google around there's a bunch of them.
https://www.snip2code.com/Snippet/34721/How-to-use-CrossWalk-runtime-within-an-A

Execute Android phonegap app with opera/Chrome mobile

I have developed an android webapp with Phonegap (Cordova 2.7.0). The app needs to receive some prices pushed by a server through the use of a third party JS API (Diffusion).
The app works well on standard desktop browsers, where websockets are available, however on the Android emulator does not seem to work due to this latter's lack of support for websockets.
I thus thought to use a different mobile browser, such as Opera or Chrome, however I now have the problem of ensuring Android uses this new browser, when executing my webapp, rather then the standard one.
Does anyone know how to do this?
Thanks.
PhoneGap for Android uses WebView, not a browser.
The simplest solution is to use a Web sockets plugin for PhoneGap, or to write your own such plugin if you cannot find an existing one that you like.
It is theoretically possible to rewrite PhoneGap to use the Android version of Chromium, but this will be a massive undertaking.

worklight poor performance on android

I'm currently testing worklight and I noticed a huge loss of performance on android devices compared to iOs ones. (tested on asus nexus 7 vs iphone 4)
The first point was: A simple html page jerks during a simple jquery mobile page transition.
No server calls.
I removed the jQuery mobile transition as it uses a lot of javascript instead of css3 transitions capabilities, but it still continue to tilt from a page to another.
I mean there's a 1/10 second 'blank screen' between 2 pages and the rendering of the next page lags.
To analyze that issue, I removed the worklight layer and hosted my simple html/jquery mobile page on an apache web server and called it from my device's chrome browser.
It worked perfectly fluid even with transitions.
After, I analyzed the worklight generated code in the mobile browser simulator and it appears that there's a lot of wlclient javascript files in the , which is not a good way of implementing a web page from my point of view, and what's more a mobile one.
Is there a way to compile all those files in one to avoid multiple http requests to the server ?
Is there a way to avoid to load all the client api if we just need a small part? I mean, if I don't need encryptedcache, why load the related js?
Is there a way to force the browser engine to use inside the app (chrome, opera, android native...) in order to test the perf of each one?
Worklight 5.0.5.20121217-0622
Android 21.0.0.v201210310015-519525
Win 7 64bit
Eclipse 3.7.2
Thanks a lot for your help.
removed the jQuery mobile transition as it uses a lot of javascript
instead of css3 transitions capabilities, but it still continue to
tilt from a page to another.
You can choose not to use jQuery Mobile and implement animations on your own or use another UI framework. You can also try creating custom CSS-based transitions for jQuery Mobile.
I removed the worklight layer and hosted my simple html/jquery mobile
page on an apache web server and called it from my device's chrome
browser
Worklight's file are not hosted on any server, they are part of the .apk you install on your device. The performance in the Web View is different than the performance in other browsers such as Google Chrome. You can try to improve it by looking at what other people are doing.
Is there a way to compile all those files in one to avoid multiple
http requests to the server ?
There's no way to do it as part of the 'Build all and deploy' step. You can edit the contents of the native folder generated for each environment and manually put the contents into a single file. However, I would not recommend that approach since those changes will get overwritten when you 'Build All and Deploy'. Read this if you want to minify your resources using Ant, however I doubt it will notably improve performance.
Is there a way to avoid to load all the client api if we just need a
small part? I mean, if I don't need encryptedcache, why load the
related js?
No, you can do it manually if you read my reply to the question above.
Is there a way to force the browser engine to use inside the app
(chrome, opera, android native...) in order to test the perf of each
one?
No, you Worklight uses Apache Cordova and that uses the Web View provided by the Android API.

Phone Gap or native Android wrapper?

I want to develop an application which works both in a regular browser and as an Android app. Both seem suitable but would I be right in saying if I went with Phone Gap, deploying the same html content as a regular, server hosted website is not trivial and would require modification? Also, are multi page applications not desirable in a Phone Gap wrapper?
Are there any alternatives I should consider? I'm surprised someone hasn't already written an Android wrapper with all the hardware access wiring done already. Or have they?
There are few things you should know,
If you are going to publish your app also on iOS, you can't use server hosted website for your app.
All of your basic functionality must stand on your app assets, is one of the iOS guidelines, and its also make-sense for best ui performance (both iOS & Android).
Use server-side wisely, when you want to fetch data which have to be up-to-date.
there are some new mobile browser features which will be available in the future, that allow your website to use the device hardware functions:
Device API on W3C
Good luck dude ;)
You can try with jquery mobile framework:
http://www.jquerymobile.com
It is jquery based framework for developing web apps that works on standard web and on multiple mobile devices (with cordova)

Categories

Resources