Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 849
Works On Mine Avatar asked Sep 19 '14 16:09

Works On Mine


2 Answers

Yes, widgets are native Android constructions. But you CAN create your widget for your app with the help of cordova plugin called "cordova-plugin-ace". Made by Microsoft and opened to everyone.

Documentation:

  • Official site - http://microsoft.github.io/ace/
  • Doc for creating widget - http://microsoft.github.io/ace/docs/native-ui/#four

I hope it'll be helpfully for you, me and others cordova devs.

like image 200
Slava Shengur Avatar answered Oct 20 '22 11:10

Slava Shengur


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

like image 27
andmar8 Avatar answered Oct 20 '22 11:10

andmar8