Works On Mine Works On Mine - 23 days ago 13
Android Question

Android Widget using Cordova

I am planning to bundle together some minimal functionality into an app or a widget for android devices. However on second thought I realized that I have never heard/read someone building a widget with Cordova/Phonegap before. I googled a bit and the answers seem to be suggesting a 'no'. I read the description on the home page for Phonegap and it says that it allows users to build apps basically.

So, could someone please point me in the right direction as to wether its possible to create an android widget in Cordova. And if no, how is an widget conceptually/practically different from an app.

PS: just maybe i am using some incorrect terminology here. What I mean by a widget is this. Its something that sticks on the home screen mostly in a translucent bar.

Answer

Widgets are android native constructs that extend a view on the application screen.

http://developer.android.com/reference/android/widget/package-summary.html

A cordova/phonegap app is an app with a webview backing. Note: webview not android native view.

Until someone finds a way to construct a native widget that embeds a webview, then what you have been told so far is correct... i.e. "no".

http://cordova.apache.org/docs/en/4.0.0/guide_overview_index.md.html#Overview http://cordova.apache.org/docs/en/4.0.0/guide_hybrid_webviews_index.md.html#Embedding%20WebViews http://cordova.apache.org/docs/en/4.0.0/guide_platforms_android_webview.md.html#Android%20WebViews

Edit: It "is" conceivable you could have a widget associated with your cordova project, but then you would be writing android native code alongside cordova.... most people would see this as defeating the point of using cordova, unless you are ONLY targeting android. In which case I have to ask the question:

"Are you using cordova as an easier way to start app coding on android or are you trying to leverage the convenience of cordova to share a code base across multiple platforms?"

If it's the former, then just write a native app. If it's the latter, then cordova isn't going to (easily) give you widgets, nor cross platform widgets