Reputation: 969
can any one suggest me an alternative for phone gap web workers because i want my application to run successfully from android 2.2 to 4.2. As i know web workers support for 4.0 and above.
I tried Android Google cloud messaging and that is working perfectly fine. but i am looking for phone gap options not native android options.
Upvotes: 10
Views: 3682
Reputation: 380
You could try https://crosswalk-project.org, which enables you to use an modern version of a Chromium-based Webview and get rid of the system webview. It's an Intel project, the documentation is complete and concise, and it includes many examples of how to use it along Apache Cordova.
Note Web Workers API is listed as supported: https://crosswalk-project.org (as well as WebRTC, WebGL, or other less unheard-of niceties like Web Notification API, which would free you of using a Cordova plugin for launching system native notifications).
The Chrome team also made a tool for packaging Chrome Apps with Cordova via the Crosswalk Webview: https://github.com/MobileChromeApps/mobile-chrome-apps
Using Crosswalk has some caveats, though. See https://github.com/MobileChromeApps/mobile-chrome-apps/blob/master/docs/Crosswalk.md For me, the more important one is: "An increase of about 17MB in the size of the .apk file"
. Depending on the app type (mainly if it's not a game), I, as an Android user, won't install such big app.
Upvotes: 1
Reputation: 1
You could try a combination of inappbrowser and the localStorage/'storage' events.
For example. YOur background processes could run in your index.html which would bind an event handler for 'storage' using window.addEventListener('storage', function callback, true/false)
When the page loads, before hiding the s splash screen, launch another browser instance using window.open directed to ui.html (containing ui thread/html/css ect) be sure to configure the browser to be full screen with all tool/ location bars hidden.
Now in the ui.html javascript when you want to send data to the bg thread you just create it in local persistent storage. Ex localStorage.setItem ('item', data);
Now an event should fire in the original window (bg layer) triggering your callback function which will be passed an event object that contains (amoung other things) the data value that changed.
If youd like more detailed instructions let me know. I got this working in android 2.2+
Upvotes: 0
Reputation: 1066
Use push notification plugin https://build.phonegap.com/plugins/3 that encapsulate Google cloud messagging on Android
Upvotes: -1