Is it possible to create a widget with javascript?

Asked

Viewed 431 times

-4

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

  • 1

    Look, I think your question is too broad and opinionated, but since I’m a long way from being an expert on this, I’m not going to vote or signal or anything. However, the reason the question did not receive much attention may have been why.

  • @Victorstafusa, if you want and can, you can edit the question to try to improve it

  • @Anderson the Ordova probably uses the API Vibrate under the table, I didn’t ask that question about any project, just to get to know it. If you already have something or at least a sketch, I believe apple has not even thought to do something, at least for now. Windows phone is dead, I won’t even waste time. As I referred to a pwa I thought already implied that was for mobile, but to be clear, the focus is android

  • 1

    Long story short: PWA is currently just a shortcut for the browser to open without frame, and run a worker to manage when routes will open local and remote resources. It has no functionality that "exits" from the browser and runs on OS.

  • Could downvoter say why? How can I improve the question?

  • Dear William, it’s me, your namesake again, to be honest your question doesn’t say anything about PWA, in PWA as far as I understand the application has to work independently of browsers, so that’s pretty much what Bacco said, then of the functionality cited as "vibrate" I think your question is not about PWA, so it’s one of the cases I mentioned in Meta, maybe the tag [tag:android] fits, but [tag:pwa] does not fit your question and is not your problem. Your problem is about creating an "app" shortcut, and whether it will need to be hybrid or native...

  • ... then the question is about specific functionalities of an operating system (or more), so it would fit the tags on the system, but not on pwa, just to be clear (ps: it was not I who denied or do not know the reason also, I can only assume that the person may not have understood the question, but I can not affirm anything). I await your editing the question and will have an upvote from me to counterbalance

  • @Guilhermenascimento the question could be translated to "is it possible to create a widget with javascript?" would that be better? Which tags could be added instead of pwa?

  • I think it would be perfect the title, even in old browsers, it was "possible" to create favorites, today no more, but worth the question, just one thing, I think what you want is not widget, but an icon as "shortcut", including iOS has (had support) to something like that, but it wasn’t via Javascript. I would just put the tags of the platforms that need such functionality, as Android and iOS (maybe windowsphone)

  • I was thinking of a button or something that when it was clicked do something in "pwa" without needing to open it, it would be a shortcut to certain functionality

  • Ai is no longer pwa, pwa is methodology, not technology. PWA is how it does things, not the support of something that the operating system works on itself.

Show 6 more comments

1 answer

0

From what I understand, you have a web application (HTML + CSS + Javascript) to be used as a Android Widget App.

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

According to the official guide to App Widgets:

Creating the Widget layout is simple if you’re familiar with Layouts. However, you must 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.

That summarizing in Portuguese means: Webview cannot be used in App Widgets.

Well, theoretically it can’t. It seems that some colleague of Macgyver, called Mike M. discovered a way of doing Webview work in Widget App.

That involves carrying a WebView on the outside, render the content as a bitmap, and use a ImageView to display this image.

I do not recommend using this method if the application needs to do some advanced user interaction. Theoretically there is no way to interact with buttons, or any other gadget of your web app. Because no one’s stopping you from recreating tag map in your app, but I warn you, this is masochism.

  • The idea would be to create a widget only with HTML, CSS and JS (if possible), without having to create something with java or Kotlin that the user would have to go to the store to download and update. But if it’s not possible this is an interesting solution (if, as I said, you don’t need to interact with the user)

  • A 100% PWA solution would be to use Webapk, but this cannot be used as App Widget.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.