Is it possible to create a widget with javascript?

-4

javascript already has several apis for push notification, vibration (mobile only) among others, is it possible to create widget on the user's desktop? Or, if this is a project requirement, should I create a native application? If it is possible to do, how? If it is not possible, is there any outline or a forecast of when it would be possible?

    
asked by anonymous 22.07.2018 / 01:42

1 answer

0

As I understand it, you have a web app (HTML + CSS + JavaScript) to use as a Android App Widget .

For this, you will need to load your application using a WebView .

According to the official App Widgets guide :

  

Creating the App Widget layout is simple if you're familiar with   Layouts. However, you should be aware that App Widget layouts are based   on RemoteViews, which do not support every kind of layout or view   widget.

     

A RemoteViews object (and, consequently, an App Widget) can support   the following layout classes:

     
  • FrameLayout
  •   
  • LinearLayout
  •   
  • RelativeLayout
  •   
  • GridLayout
  •   

And the following   widget classes:

     
  • AnalogClock
  •   
  • Button
  •   
  • Chronometer
  •   
  • ImageButton
  •   
  • ImageView
  •   
  • ProgressBar
  •   
  • TextView
  •   
  • ViewFlipper
  •   
  • ListView
  •   
  • GridView
  •   
  • StackView
  •   
  • AdapterViewFlipper
  •   

Descendants of these classes are not supported.

What a summary in English means: WebView can not be used in App Widgets .

Well, theoretically it can not. It looks like someone from the MacGyver , called Mike M. has figured out a way to do WebView work in App Widget .

It involves loading a WebView on the outside, rendering the content as a bitmap, and using ImageView to display this image.

I do not recommend using this method if the application needs to do some advanced user interaction. In theory there is no way to interact with buttons, or any other gadget in your web app . Because nobody keeps you from re-creating the tag map in your app, but I'll let you know , this is masochism.

    
31.07.2018 / 02:46