petekanev / ns-androidWidget-App-Demo

The project demonstrates how to implement Android Widget using mainly JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Steps to create an Android App Widget in NativeScript

  • Create an android layout for your widget and place it in platforms/android/src/main/res/layout. Make sure to follow the official guidelines as not all views are supported.
  • Create a widget meta-data file and place it in platforms/android/src/main/res/xml/.
  • Extend android.appwidget.AppWidgetProvider and implement its onUpdate method. For more information on how to do it refer to the Android API Guides.
  • Update the AndroidManifest.xml located in platforms/android/src/res/ and register your widget, where receiver android:name=??? contains the full widget class name, and meta-data android:resource=@xml/??? - your widget meta-data.

Note: Make sure to include the newly created files and folders in version control in case your platforms/* is excluded by default.

Note 2: A full widget class name is only considered valid when it contains package descriptor eg. com.tns or a.b in the front.

How to run

  • Run command in your terminal
tns run android
  • Add the widget from the application WidgetDemo to your home screen.
  • Clicking on the button on the right will increase the tap counter, while clicking on the image will open the application with which the widget is associated.

Preview

Widget demo

About

The project demonstrates how to implement Android Widget using mainly JavaScript


Languages

Language:JavaScript 92.1%Language:Java 7.8%Language:CSS 0.0%